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 has no maxZoom specified #46

Open
bpatrik opened this issue Apr 30, 2021 · 1 comment
Open

Map has no maxZoom specified #46

bpatrik opened this issue Apr 30, 2021 · 1 comment

Comments

@bpatrik
Copy link
Contributor

bpatrik commented Apr 30, 2021

This is just an FYI issue, if anyone else runs into this:

markercluster throws error Map has no maxZoom specified if max zoom is not specified.
A solution can be specifying max zoom, but than that would override the tile's max zoom (leading to too little, or too much zoom)

Relevant code part that cause the issue:

    <div
      leaflet
      [leafletOptions]="mapOptions"
      (leafletMapReady)="onMapReady($event)">
    </div>   
mapOptions: MapOptions = {
    zoom: 2,
    center: latLng(0, 0),
    layers: [markerClusterGroup()]
  };

Possible workaround:

  1. setting dummy max zoom by default:
mapOptions: MapOptions = {
    zoom: 2,
    // setting max zoom is needed to MarkerCluster https://github.com/Leaflet/Leaflet.markercluster/issues/611
    maxZoom: 2,
    center: latLng(0, 0),
    layers: [markerClusterGroup()]
  };
  1. Then removing it once the map loaded, so it can fallback to the tile's max zoom:
onMapReady(map: Map): void {
    this.leafletMap = map;
    this.leafletMap.setMaxZoom(undefined);
  }

Related issue at leaflet: Leaflet/Leaflet.markercluster#611

@bpatrik
Copy link
Contributor Author

bpatrik commented Apr 30, 2021

The solution in Leaflet/Leaflet.markercluster#611 is not working for ngx-leaflet-markercluster as the layers added to the map earlier than onMapReady is called.

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

No branches or pull requests

1 participant