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

Location view should zoom to the extent of the geometry #377

Closed
bjohare opened this issue Jul 11, 2016 · 1 comment · Fixed by #385
Closed

Location view should zoom to the extent of the geometry #377

bjohare opened this issue Jul 11, 2016 · 1 comment · Fixed by #385
Assignees
Labels
Milestone

Comments

@bjohare
Copy link
Contributor

bjohare commented Jul 11, 2016

When looking a locations within a project, the map should zoom to the extent of the geometry. This seems to work for point / multiple points but is at incorrect zoom level for polygon geometries.. user needs to zoom out to see full polygon extent.

@bjohare bjohare added the bug label Jul 11, 2016
@wonderchook wonderchook added this to the Post July Release Sprint milestone Jul 11, 2016
@seav
Copy link
Contributor

seav commented Jul 11, 2016

OK. I think this is a bug in Leaflet. The current code has the following summarized code:

var data = LOCATIONS_DATA_AS_GEOJSON;
var geoJson = L.geoJson(null, {onEachFeature: SOME_FUNCTION});
geoJson.addData(data);
map.fitBounds(geoJson.getBounds());

This roughly fits the locations into the map view, but some parts at the fringes are cut off.

However, if I replace the last line with either of the following options (basically creating a pristine L.geoJson object), the map view displays correctly:

// Option 1
map.fitBounds(L.geoJson(data).getBounds());
// Option 2
var newGeoJson = L.geoJson();
newGeoJson.addData(data);
map.fitBounds(newGeoJson.getBounds());

I'm applying the Option 1 workaround to the platform.

I would have liked to report this upstream but since Leaflet is gearing up for a v1.0.0 release, I doubt this bug (which occurs in Leaflet v0.7) will get fixed.

seav added a commit that referenced this issue Jul 11, 2016
ian-ross added a commit that referenced this issue Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants