I've got loads of coordinates for a polygon in a database. I also have coordinates for an marker in my database. How do i detect if the marker is inside this polyon.
Note: I use a cronjob to move the marker, and in this cronjob it needs to detect this. So javascript isn't involved!
Shape of polygon is not just a circle or square. It could be for example a country or sea.
There is now a function in the Google Map API that does that.
Google Map coordinates in polygon
containsLocation(point:LatLng, polygon:Polygon);
isLocationOnEdge(point:LatLng, poly:Polygon|Polyline, tolerance?:number);
you should SELECT your polygons and SORT them in two different forms one by the x-axis, one by the y-axis, each time GROUPing them by the same parameter. then make sure the y coordinate of you marker point is between the y-coordinates of the polygon points of the same x. and that the marker y is between the x of the polygon points with the same y.
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