Search for 'point in polygon'
useful examples
http://alienryderflex.com/polygon/
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/b2aeb4f444dbe410/e159b0f5c9248c09
The function is as follows:
google.maps.Polygon.prototype.Contains = function(point) {
var j = 0;
var func_oddNodes = false;
var x = point.lng();
var y = point.lat();
var poly = this.getPath();
for (var i=0; i < poly.getLength(); i++) {
j++;
if( j == poly.getLength() ) {
j = 0;
} // end if
if ( ((poly.getAt(i).lat() < y) && (poly.getAt(j).lat() >= y))
|| ((poly.getAt(j).lat() < y) && (poly.getAt(i).lat() >= y)) ) {
if ( poly.getAt(i).lng() + (y - poly.getAt(i).lat())
/ (poly.getAt(j).lat()-poly.getAt(i).lat())
* (poly.getAt(j).lng() - poly.getAt(i).lng())<x ) {
func_oddNodes = !func_oddNodes
} // end if
} // end if
} // end for
return func_oddNodes;
} // end function
And to make the call to it:
mypolygon.Contains(mypoint);
I have it on a site that is up for now, (I'm working to replace it
soon) its @ http://www.cadistrict38.org/new/2011/m.php, just click
submit on that first pane and then enter in any name and try location
"Lakewood, CA" and it should spit back "within Lakewood"
Hope this helps!
On Nov 18, 4:43 pm, Zachary DeBruine <zacharydebru...@gmail.com>
wrote:
That is from Mike Williams' v2 tutorial:
http://econym.org.uk/gmap/
Third Party Extensions
Part 12 Using EPoly - extra methods for polygons and polylines.
http://econym.org.uk/gmap/epoly.htm
There are several ports of it to v3.
-- Larry
> soon) its @http://www.cadistrict38.org/new/2011/m.php, just click