Phillip Schmidt
Phillip Schmidt

Reputation: 8818

Google maps bounding polygons

I need to be able to do spatial queries to determine if a lat/long coordinate exists inside a polygon. I know that you can define bounding boxes and do queries like that, but can you do the same with custom shapes?

As an overly simplified example, lets say I need to be able determine if a lat/long point (X,Y) is within 20 miles of the western coast of the US. Lets say I already have the means to draw a line "parallel" to the coast, 20 miles out, and connect that line to the coast line at the top and bottom. I want to test if the point (X,Y) is inside the polygon bounded by those lines.

Is this possible using the native Maps API? If not, is there an additional plugin that will allow me to do this?

Upvotes: 0

Views: 1019

Answers (1)

geocodezip
geocodezip

Reputation: 161334

The Google Maps API v3 includes the containsLocation method, which takes a LatLng and a Polygon and returns a boolean. Not sure what you mean by the "native Maps API".

Upvotes: 2

Related Questions