Looking for a way to count the number of markers inside a polygon which is drawn dynamically by the user
The code below can draw the polygon now i want to show the count of number of markers inside the polygon if there exists
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple Polygon</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.17&AIzaSyBLnIMoOLvgLaeIUEzLX3sIw0-FOXwXcag"> </script>
<script>
function initMap() {
var mapOptions={
center:{lat: 27.174977,lng:78.042064},
zoom: 8
};
var map15= new google.maps.Map(document.getElementById("map"),mapOptions);
var polygon= new google.maps.Polygon({
strokeColor: "#1E41AA",
strokeOpacity: 1.0,
strokeWeight: 3,
map: map15,
fillColor: "#2652F2",
fillOpacity: 0.6
});
var poly= polygon.getPath();
function addPolyPoints(e){
poly.push(e.latLng);
}
google.maps.event.addListener(map15,'click',addPolyPoints);
}
initMap();
</script>
</body>
</html>
ie, when the user draw the polygon the map if there exists a marker the count should be provided.
How to do it?