Is it possible to select multiple markers on google map


If I have 100 markers on map and I want to do something with only 15 of them is there any way to implement this by using CTRL + click on marker or standard cursor drag selection?


Answers:


Ctrl+click is possible. Add a click event to the marker, and then in the event handler test if the CTRL key was pressed. If so, add the marker to an array that you can then do something with later.

var markers = [];
google.maps.event.addListener(marker, 'click', function (event) {
  if (event.ctrlKey) {
    markers.push(marker);
    // some more code to change icon, add marker name to list, etc 
    //   so user knows marker has been selected
  }
});

There are some issues documented using this approach, but it has worked for me every time. Just make sure to test in multiple browsers.

See this Stack Overflow question for a drag-box-to-select-markers implementation.