Skip to content

Expand leaflet_strawberry.js to Zoom out for Polygons and Multipolygons #574

@markpbaggett

Description

@markpbaggett

Hey all,

I'm working on a giant map collection and we have geojson polygons and multipolygons that we want to show instead of markers and marker cluster groups. The good thing is that this all currently works out of the box. The only problem is that the Zoom level logic is missing for polygons.

We're joining AllMaps so we expect to have lots of georeferenced content like this. Can we add a tiny bit of code so zoom level works:

    geojsonLayer.on('data:loaded', function () {
      if (!cluster_added) {
        markers.addLayer(geojsonLayer);
        map.addLayer(markers);
        // Use geojsonLayer bounds so that Zoom level works for both points and polygons
        if (geojsonLayer.getBounds().isValid()) {
          map.fitBounds(geojsonLayer.getBounds());
        }
      cluster_added = true;
      }
    });

Metadata

Metadata

Assignees

Labels

Field FormatterThe thing that glues the pieces and adds glitterJavascriptFavourite language of a PHP developerUI driven hintsShow stuff on screen so people have less guessing to doenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions