diff --git a/home/App.tsx b/home/App.tsx index aa4954f..58526b2 100644 --- a/home/App.tsx +++ b/home/App.tsx @@ -6,6 +6,7 @@ import Polygons from "./Polygons"; import Element from "./Element"; import RouteInfo from './RouteInfo' import MapElement from './MapElement' +import Clustering from './Clustering' declare global { interface Window { @@ -23,6 +24,7 @@ const App = () => { + ) } diff --git a/home/Clustering.tsx b/home/Clustering.tsx new file mode 100644 index 0000000..7fb3022 --- /dev/null +++ b/home/Clustering.tsx @@ -0,0 +1,68 @@ +import React from 'react'; +import styled from "styled-components"; +import {CompassControl, KeyboardControl, MouseControl, SyncControl, ZoomControl} from "../src/controls"; +import {Map, Marker, MarkerLayer} from "../src"; +import {githubGist} from "react-syntax-highlighter/dist/esm/styles/hljs"; +import SyntaxHighlighter from "react-syntax-highlighter"; +import Section from "./components/Section"; + +const SElement = styled(Section)` + display: flex; + justify-content: space-evenly; + align-items: center; +`; + +const Clustering = () => { + const code = ` + + + + + + + + + + + ` + + const markerCard = { + header: "Card header", + body: "

Card body

", + footer: "Card footer", + options: { + width: 200, + height: 200, + } + } + + return ( + +
+ + + + + + + + + + + + + + + {code} + +
+ +
+ ) +} + +export default Clustering; diff --git a/src/Map.tsx b/src/Map.tsx index c4ef449..8f79862 100644 --- a/src/Map.tsx +++ b/src/Map.tsx @@ -37,18 +37,29 @@ const handleEventListener = (e: MapEvent, sMap: unknown, onEvent: MapEventListen onEvent(e, coordinates) } + const Map = (props: MapProps) => { const mapNode = useRef(null); const [map, setMap] = useState(null); const {width, height, children, onEvent, eventNameListener = "*", zoom, center, animateCenterZoom} = props; + const customLayer = new window.SMap.Layer.WMS(null, "https://services.cuzk.cz/wms/local-km-wms.asp", {layers:"KN,bp,bp_ppbp"}); + + useEffect(() => { if (!map && mapNode) { const centerCoords = center ? window.SMap.Coords.fromWGS84(center.lng, center.lat) : undefined; const sMap = new window.SMap(mapNode.current, centerCoords, zoom); - const l = sMap.addDefaultLayer(props.baseLayer ?? BaseLayers.TURIST_NEW); + // const l = sMap.addDefaultLayer(props.baseLayer ?? BaseLayers.TURIST_NEW); + + console.log('-- layer --', customLayer) + const l = sMap.addLayer(customLayer); l.enable(); + console.log('-called-') + + // + setMap(sMap); if (onEvent) { const signals = sMap.getSignals(); diff --git a/src/MarkerLayer.tsx b/src/MarkerLayer.tsx index a2a4cec..baa9553 100644 --- a/src/MarkerLayer.tsx +++ b/src/MarkerLayer.tsx @@ -19,7 +19,7 @@ const MarkerLayer = ({children, enableClustering, clusterConfig, id}: MarkerLaye const clusterer = new window.SMap.Marker.Clusterer( map, clusterConfig?.maxDistance, - clusterConfig?.clusterCtor + window.SMap.Marker.Cluster(id, { color: "#ff0000"}) ); markerLayer.setClusterer(clusterer); } @@ -37,4 +37,4 @@ const MarkerLayer = ({children, enableClustering, clusterConfig, id}: MarkerLaye return {children}; } -export default MarkerLayer; \ No newline at end of file +export default MarkerLayer;