Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to find all the markers inside a polygon in a Google map?

Multiple markers (points) are plotted inside a google map and a user is given an option to draw a polygon using a drawing library. Now I need to find out which markers are inside a drawn polygon in the Google map. To achieve this I have used the "google.maps.geometry.poly.containsLocation()" google map API function which accepts a polygon object and a marker as parameters and returns whether the given marker is inside the polygon or not.

But it's costly in terms of performance as I need to iterate through all the markers plotted inside the Google map and need to invoke the function multiple times passing each marker as a parameter in the function. Can anyone suggest any alternate option to achieve this tuning the performance?

Comments