<script async defer src="//maps.googleapis.com/maps/api/js?sensor=false&callback=initialize"></script>
function initialize() {
var map;
var bounds = new google.maps.LatLngBounds();
var mapOptions = {
mapTypeId: 'roadmap',
styles: [
{
"featureType": "water",
"elementType": "geometry",
"stylers": [
{
"color": "#f3f3f3"
},
{
"lightness": 1
}
]
},
{
"featureType": "landscape",
"elementType": "geometry",
"stylers": [
{
"color": "#95979a"
},
{
"lightness": 1
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#ffffff"
},
{
"lightness": 17
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#ffffff"
},
{
"lightness": 29
},
{
"weight": 0.2
}
]
},
{
"featureType": "road.arterial",
"elementType": "geometry",
"stylers": [
{
"color": "#ffffff"
},
{
"lightness": 18
}
]
},
{
"featureType": "road.local",
"elementType": "geometry",
"stylers": [
{
"color": "#ffffff"
},
{
"lightness": 16
}
]
},
{
"featureType": "poi",
"elementType": "geometry",
"stylers": [
{
"color": "#f5f5f5"
},
{
"lightness": 21
}
]
},
{
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [
{
"color": "#dedede"
},
{
"lightness": 21
}
]
},
{
"elementType": "labels.text.stroke",
"stylers": [
{
"visibility": "on"
},
{
"color": "#ffffff"
},
{
"lightness": 16
}
]
},
{
"elementType": "labels.text.fill",
"stylers": [
{
"saturation": 36
},
{
"color": "#333333"
},
{
"lightness": 40
}
]
},
{
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "geometry",
"stylers": [
{
"color": "#f2f2f2"
},
{
"lightness": 19
}
]
},
{
"featureType": "administrative",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#fefefe"
},
{
"lightness": 20
}
]
},
{
"featureType": "administrative",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#fefefe"
},
{
"lightness": 17
},
{
"weight": 1.2
}
]
}
]
};
// Display a map on the page
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
map.setTilt(45);
google.maps.event.addDomListener(window, "load", initialize);
// Multiple Markers
var markers = [
['India, IST', 20.5937, 78.9629],
['Metropolitan France, France', 47.0000, 2.0000],
['Akrotiri and Dhekelia, Akrotiri', 34.5803, 32.9743],
['Australia, Sydney', -33.86785, 151.20732],
['Dubai, GST', 25.276987, 55.2708],
['South Africa, cape town', -33.9249, 18.4241],
['USA, cape town', 42.032974332441405, -102.3046875]
];
// Info Window Content
var infoWindowContent = [
['<div class="info_content">' +
'' +
'<p>12:30 PM IST</p>' + '</div>'],
['<div class="info_content">' +
'<h3></h3>' +
'<p>08:00 AM CET</p>' +
'</div>'],
['<div class="info_content">' +
'' +
'<p>09:00 AM EET </p>' + '</div>'],
['<div class="info_content">' +
'' +
'<p>06:00 PM AEDT</p>' + '</div>'],
['<div class="info_content">' +
'' +
'<p>11:00 AM GST</p>' + '</div>'],
['<div class="info_content">' +
'' +
'<p>09:00 AM SAST</p>' + '</div>'],
['<div class="info_content">' +
'' +
'<p>11:00 PM PST</p>' + '</div>']
];
// Display multiple markers on a map
var infoWindow = new google.maps.InfoWindow(), marker, i;
// Loop through our array of markers & place each one on the map
for (i = 0; i < markers.length; i++) {
var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
bounds.extend(position);
marker = new google.maps.Marker({
position: position,
map: map,
title: markers[i][0]
});
// Allow each marker to have an info window
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
infoWindow.setContent(infoWindowContent[i][0]);
infoWindow.open(map, marker);
}
})(marker, i));
// Automatically center the map fitting all markers on the screen
map.fitBounds(bounds);
}
// Override our map zoom level once our fitBounds function runs (Make sure it only runs once)
var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function (event) {
this.setZoom(2);
google.maps.event.removeListener(boundsListener);
});
}
HTML View
<div id="map_canvas"></div> //More stylish Map https://snazzymaps.com/
Show Comments

