Skip to content Skip to sidebar Skip to footer

Google Map Iterate Through All The Objects

I am dynamically loading json map data. Once the data is loaded, I wanted to iterate over all items (Features) on the map. Then I want to add a 'listener' when a user clicks on the

Solution 1:

You can add a click listener to the data layer like this google example, replacing the "mouseover" with "click" (outside of the .forEach).

// Set click event for each feature.
map.data.addListener('click', function(event) {
  console.log('click'); 
});

Post a Comment for "Google Map Iterate Through All The Objects"