StackOverflowNewbie
StackOverflowNewbie

Reputation: 40633

Google Maps: how to find map boundaries?

Is there a function in Google Maps API that will return an array of lat/lng values defining a polygon for a given location? For example:

If not available in Google Maps API, is there some online source I can get this info from?

Upvotes: 0

Views: 2512

Answers (2)

SimonSays
SimonSays

Reputation: 156

I think it depends if you want the bounds of a pre-defined polygon or if you are making your own polygon for the state of Nevada for example. If you are doing you own then you can use build in functions to get the lat/longs. If you are looking for predefined ones then you will need to dig them up as they don't exist in v3 to my knowledge.

This nice guy has provided the states in XML format if that helps?

US States Graphical Boundaries

If you are looking to get the bounds of an existing polygon, then here is a method that works in V3:

Get the bounds of a polygon in Google Maps V3

Upvotes: 0

Marcelo
Marcelo

Reputation: 9407

If you only want the bounding box then you can use the geocoding service, for example

and read results[0].geometry.bounds.northeast and results[0].geometry.bounds.southwest

On the other hand, if you want exact political borders you need to download and process shapefiles from somewhere, like Natural Earth Data or the US Census Bureau

Upvotes: 2

Related Questions