Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map resets zoom after marker selection. #78

Closed
natikos opened this issue Oct 24, 2020 · 1 comment
Closed

Map resets zoom after marker selection. #78

natikos opened this issue Oct 24, 2020 · 1 comment
Labels

Comments

@natikos
Copy link

natikos commented Oct 24, 2020

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;
@kadoshms kadoshms added the bug label Oct 26, 2021
@kadoshms
Copy link
Owner

Closing for inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants