Is there a way to determine if a marker has entered an area covered by a KmlLayer? My .kml is mostly made up of a <Polygon>
with a bunch of coordinates that define the boundary.
There is an article I found that describes some similar to what I'm looking for, created using an overlay: http://www.paulmcilwaine.com/api/google-maps-detecting-markers-in-a-particular-boundary
That method has the advantage of using getBounds(), but I am looking for a way to do this with a KmlLayer boundary. KmlLayer doesn't seem to have a handy function like getBounds(), but I do have all the coordinates available to me in the KML file itself, so I'm thinking there's a way to create my own getBounds() function. I just need a way to determine if a marker (or a latlang) is inside those coordinates in the KML file.
Thanks for any ideas!
There is no such function on KmlLayer. However, if you can extract the polygon boundaries, and create a polygon you can use the Geometry library of the Maps API to determine if the point lies inside the polygon: https://developers.google.com/maps/documentation/javascript/reference#poly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With