Question

I am using jquery-ui map plugin to manipulate some maps

I am using overlays from a kml file and afterwards I am adding a marker, my goal is to see in which overlay's territory the marker was added Any ideas? My code can be found here

http://jsfiddle.net/theodore/twGHC/268/

Was it helpful?

Solution

Proof of concept

Uses:

  • geoxml3 to parse the (your) KML and add it to the map as native Google Maps API v3 objects
  • the geocoder to place a marker (for convenience), you didn't specify your method
  • the Google Maps API v3 geometry library to determine which polygon contains the marker

Based off of this Google Maps API v2 example, which was ported to the Google Maps API v3.

OTHER TIPS

It's been tough to find, but here it is. You should use containsLocation , methods of poly* namespace. (poly).

Quoting #Neograph734

var polyOptions = {
 ...
}

draw = new google.maps.Polygon(polyOptions);
draw.setMap(map);

if(google.maps.geometry.poly.containsLocation(point, draw) == true) {
 alert("yes");
}

See how-to-use-containslocation-in-google-maps-geometry-library

Please, note that polygons have events. So if in your actual application, the marker is added by the user, use the click event from the polygons (Polygon)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top