Closed natikos closed 2 years ago
I handle selection markers by myself. When user zoom in and selects a marker, then map resets zoom and go to full-size mode (scale = 1).
There are appropriate functions.
onMarkerClick={(e, index) => { const isNew = !shownLabelIndexes.includes(index); const newArray = isNew ? [...shownLabelIndexes, index] : shownLabelIndexes.filter(el => el !== index); setShownLabelIndexes(newArray); // map.setScale(markerSelectionZoom); map.scale = markerSelectionZoom; }} onViewportChange={(e, scale) => { if (map && scale !== 1) { markerSelectionZoom = scale; map.scale = scale; } }}
and here my variables and state in components:
const [shownLabelIndexes, setShownLabelIndexes] = useState([]); const [ref, { width }] = useDimensions(); const mapRef = useRef(null); const map = mapRef.current && mapRef.current.getMapObject(); let markerSelectionZoom = 1;
Closing for inactivity.
I handle selection markers by myself. When user zoom in and selects a marker, then map resets zoom and go to full-size mode (scale = 1).
There are appropriate functions.
and here my variables and state in components: