Extending Bounds For Polygons -- Google Maps V3 Javascript API -
my goal detect if marker within oddly shaped polygon object (think 25 different points). have noticed latlngbounds property, contains 2 sets of latlngs, after using .extend function, example:
((34.347971491244955, -122.40966796875), (34.829586636768205, -120.9649658203125))
is normal behavior?
the code below tiny snippet of program building, contains relevant information how using extend function. have idea how detect if marker within oddly shaped polygon, if can't use combination of .extend() , .contains()?
var coordinates = (polygon.getpath().getarray()); //get var bounds = new google.maps.latlngbounds(); function extendbounds(bounds, coordinates) { (b in coordinates) { bounds.extend(coordinates[b]); }; console.log(bounds.tostring()); };
the bounds of polygon rectangle. if want detect if marker in polygon use containslocation function in google.maps.geometry.poly namespace, passing polygon , position of marker
containslocation(point:latlng, polygon:polygon) | boolean | computes whether given point lies inside specified polygon.
Comments
Post a Comment