Search code examples
google-mapsgoogle-maps-api-3google-maps-api-2

How to show multiple markers on google map


I m new to google map API. My question is can we show multiple markers on the map using the API???


Solution

  • Yes, yes you can. Just call the new google.maps.Marker() function for each marker location you want to add to your map.

    I assume you've already got a map created, called 'map'. This will add 2 markers to it.

    var marker1 = new google.maps.Marker({
        position: new google.maps.LatLng(24.696554,-81.328238),
        map: map
    });
    
    var marker2 = new google.maps.Marker({
        position: new google.maps.LatLng(50.815155, -0.137072),
        map: map
    });