0

Using Gmap3, I have a map set which shows some location but has no markers. Now how can I use javascript/jquery so I can add markers to the map? Basically I have an array with data, that I want to loop through and add markers to the map with that.

Thanks.

omega
  • 40,311
  • 81
  • 251
  • 474

1 Answers1

0

I haven't used gmap3 but I think something like this will work. Check this out for a non-gmap3 solution.

var locations = [
    [47.003088, -96.929448],
    [46.817268, -96.810024],
    [46.842064, -96.796163]
];

$("#test").gmap3({
    map:{
        options:{
        center:[46.842064, -96.796163],
        zoom: 5
    }
 }

for (var i = 0; i < locations.length; i++) {  
   $("#test").gmap3({         
        marker:{
           latLng: locations[i]
         }
   });
}
Community
  • 1
  • 1
Alkis Kalogeris
  • 17,044
  • 15
  • 59
  • 113