logo
Blog single photo

set multiple location with icon resize using google map


                        

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR API&callback=initMap&sensor=false"></script>
<div id="map" style="height: 400px; width: 100%;">
<script type="text/javascript">
    var locations = [
      <?php echo $location; ?>
    ];
    var image = {url:'YOUR IMG URL HERE',
        scaledSize : new google.maps.Size(50, 50),
    };

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 12,
      center: new google.maps.LatLng(<?php echo $center_location; ?>),
      mapTypeId: google.maps.MapTypeId.ROADMAP
     
    });

    var infowindow = new google.maps.InfoWindow();
    var marker, i;
    for (i = 0; i < locations.length; i++) {
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map,
        icon: image
      });

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>

Top