I need to plot a set of coordinates on the map in response to a user selection, and when it happens, I’d like to pan the map to focus on that set of points. How can I find the smallest bounding box (LatLngBounds) that contains all of the coordinates?
Share
In addition to the Stack Overflow post which @Crescent Fresh pointed to above (which is using the v2 API), the method you’d want to use is the
LatLngBounds.extend().Here’s a complete example, using the v3 API:
Screenshot: