I have a map with various markers, and I need to draw a rectangle on the map and select the markers that are within the rectangle.
So far I have found excellent information here: How to get the markers inside the area selected by dragging and dropping?
I implemented the keymapzoom plugin in order. So
$('#dispatcher').gmap3({action:'get'}).enableKeyDragZoom({ boxStyle: { border: "dashed black", //backgroundColor: "red", opacity: 0.5 }, paneStyle: { backgroundColor: "gray", opacity: 0.2 } }); var dz = $('#dispatcher').gmap3({action:'get'}).getDragZoomObject(); google.maps.event.addListener(dz, 'dragend', function (bnds) { alert(bnds); });
This gives me the following (( lat, long ), ( lat, long )) format from the warning (bnds);
I need to know how now I can check if there are any markers in it?
I already have an object that stores markers for another reason. as:
markers[name] = {}; markers[name].lat = lati; markers[name].lng = longi;
which might be useful?
I do not understand how to use GLatLngBounds and containsLatLng (latlng: GLatLng) as suggested.
Vince lowe
source share