Display multiple google map locations using latitude and longitude

Posted on September 28, 2015 by Suresh Kamrushi in Javascript

Here i am sharing how you can show multiple location on google map using Google API latitude and longitude.
create a html file as “index.html” and add below code your body tag.

<script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script><script type="text/javascript">// <![CDATA[
var markers = [{"lat":"17.454000","lng":"78.434952"},{"title":"shilparamam","lat":"17.452665","lng":"78.435608","description":"Mumbai formerly Bombay, is the capital city of the Indian state of Maharashtra."},{"title":"image hospitals","lat":"17.452421","lng":"78.435715","description":"Pune is the seventh largest metropolis in India, the second largest in the state of Maharashtra after Mumbai."}];
window.onload = function () {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
var infoWindow = new google.maps.InfoWindow();
var lat_lng = new Array();
var latlngbounds = new google.maps.LatLngBounds();
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.open(map, marker);
})(marker, data);


// ]]></script></pre>
<div id="dvMap" style="width: 500px; height: 500px;"></div>

Open the file in browser and you will see google map with all locations pointed as below:

multiple location using google map

multiple location using google map