JavaScript: multiple Google Maps pointers
popup details
by ian_smithz
HTML
<script src="https://maps.google.com/maps/api/js?sensor=false"></script>
<div id="map_canvas"></div>
CSS
#map_canvas {
width: 500px;
height: 400px;
margin: 2em auto;
}
JavaScript
var markers = [
['Bondi Beach', -33.890542, 151.274856],
['Coogee Beach', -33.923036, 151.259052],
['Cronulla Beach', -34.028249, 151.157507],
['Manly Beach', -33.80010128657071, 151.28747820854187],
['Maroubra Beach', -33.950198, 151.259302]
];
function initializeMaps() {
var myOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
var infowindow = new google.maps.InfoWindow();
var marker, i;
var bounds = new google.maps.LatLngBounds();
var popupContent = '<div id="locationContent" style="min-width:15em">'+
'<p class="marginbottom5"><strong>' + location.title + '</strong></p>'+
'<address class="nomargin">'+
'' + location.addressline1 + '<br>'+
'' + location.addressline2 + '<br>'+
'</address>'+
'<hr style="margin-top:5px; margin-bottom:5px">'+
'<p style="margin-top:5px; margin-bottom:5px"><a href="' + location.moreInfoUrl + '" class="btn btn-sm pull-right">More info</a>'+
'' + location.product + '<br>'+
'' + location.product2 + ''+
'</p>'+
'<hr style="margin-top:0px; margin-bottom:5px">'+
'<p style="margin-top:5px; margin-bottom:5px">Circuit ref <span class="pull-right">' + location.circuitRef + '</span>'+
'<br>Status <strong class="' + location.statusStyle + ' pull-right">' + location.status + '</strong></p>'+
'</div>';
for (i = 0; i < markers.length; i++) {
var pos = new google.maps.LatLng(markers[i][1], markers[i][2]);
bounds.extend(pos);
marker = new...