question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for map.fitbounds

See original GitHub issue

When it is difficult to calculate the correct zoom level to show an specific area of the map, google maps allow the use of Map.fitBounds. It basically needs only the NE and SW coordinates: https://developers.google.com/maps/documentation/javascript/reference/3/map#Map.fitBounds

I have added the support for it in my fork, and I would like to do it in the main branch if approved. My only questions is. Should this be added as a separate function? something like def fit_bounds(self, nelat, nelng, swlat, swlng): or as a different way to initialize the map. That means providing NE and SW instead of center_lat, center_lng, zoom.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
frslmcommented, Jun 1, 2020

I’ve just merged this into master in #153, you can set it by passing in a bounds literal when creating a GoogleMapPlotter object:

import gmplot

fit_bounds = {'north':37.832285, 'south': 37.637336, 'west': -122.520364, 'east': -122.346922}
gmap = gmplot.GoogleMapPlotter(37.766956, -122.438481, 13, fit_bounds=fit_bounds)
0reactions
keithstellyescommented, Nov 15, 2019

Right as you said that I found this PR and got it working:

https://github.com/vgm64/gmplot/pull/12/commits/2b5b2d634534dd2b31fc8eae566bffdc22a579d5

However that code in that PR is slightly bugged in that SW is supposed to go first, NE.

Thanks either way though! Appreciate it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google maps API V3 method fitBounds() - Stack Overflow
While I would like to render a higher level zoom. Like this. enter image description here. I use the method fitBounds() var bounds...
Read more >
Add support for map.fitbounds · Issue #77 · gmplot ... - GitHub
I have added the support for it in my fork, and I would like to do it in the main branch if approved....
Read more >
Fit a map to a bounding box | Mapbox GL JS
Fit the map to a specific area, regardless of the pixel size of the map. ... fitBounds() pans and zooms the map viewport...
Read more >
Maps JavaScript API | Google Developers
Sets the viewport to contain the given bounds. Note: When the map is set to display: none , the fitBounds function reads the...
Read more >
Support auto fit bounds for custom components
Angular Google Maps (AGM) has an auto fit bounds feature, that adds all containing components to the bounds of the map: <agm-map [fitBounds]="true"> ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found