How to acces gmap markers after map is generated? I've got a problem with Google map markers and I don't find a way to solve it.

I've got a map page view generated with the GMap module where I show certain nodes. I've got also a view block that show some of the same nodes that appear in the map in an unformatted list. What I need is to relate the nodes on the list with their respective markers in the map (so hovering the list change the marker icon or vice versa). 

I could relate the nodes with the markers since I've got the exact coordinates of the node which coincide with the marker coordinates (obviously). My problem is that I don't know how to get a list of the existing markers on the map.

From what I've read I should push the markers in an array when they're generated so later I can acces to the markers using the elements in the array, but I couldn't found where does gmap generate the markers. I've tried creating a global array and pushing the markers in the gmap_marker.js inside:

obj.bind('addmarker', function (marker) {
  // ... //
    mymarker.push(marker.marker);
}


but even I can see any result. I tried counting the markers that are generated  with something like countmarkers += 1; but the output is also 0.

Anyone has a clue on hou could I achieve this? Any advice would be appreciated.


  Edit:  Ok, I solved this problem.  It looks like what I did was fine
  and the problem was in the timing of the process. I called:

mymarkers.forEach(function(marker) {
        //funciona OK
        alert(marker.getPosition().lat() + ' - ' + marker.getPosition().lng());
    });

  
  inside a setTimeout(function(){}); with a 10ms delay. By increasing
  the delay to 5000ms all the markers have enough time to be created and
  I can finally access the markers array.
Here is a quote from the Comparison of mapping modules:

GMap is considered a legacy module.

So maybe you want to have a look at the IP Geolocation Views &amp; Maps module. Partial quote from its project page:

Despite what the name may suggest, IP Geolocation Views &amp; Maps (IPGV&amp;M) is first and foremost a mapping engine.
The module makes it very easy to create Views-based mapping solutions using the map renderer of your choice (Google, OpenLayers or Leaflet) with any location storage module of your choice, e.g.:

Get Locations,
Geofield,
Geolocation Field
Location.




This allows you to bring together modules and feature sets that without IPGV&amp;M you would not be able to combine.
Like beautiful animated marker clustering on Google or Bing or Mapbox ... any of various map providers.
But more importantly IPGV&amp;M adds some features you won't find as conveniently packaged elsewhere.
These include marker differentiation based on field values or ranges (2nd screenshot) with or without font icons, various centering options, super-imposing the current visitor's location, allowing multiple content types to be displayed on the same map, full screen button and mini-map inset (bottom screenshot), polygon support (Geofield), marker tags and tool tips and cross-highlighting of associated content on the page when markers are hovered (and vice versa).


Head over to its (impressive) project page for even more information about it (it would be way too long to include a quote of it all here). That project page also includes various screenshots.