Here i am making an functionality where i am retrieving the latitude and longitude from JSON file. and showing markers on google map.
But my problem is only one marker is showing on google map. Others is not showing.
here is my json format
{
"Data": {
"-template": "Parallax",
"Explore": {
"IslandLife": {
"TourismLocation": [
{
"Title": "Langkawi",
"Latitude": "6.350000",
"Longitude": "99.800000",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": {
"YouTubeVideoID": [
"7HlMpaSspNs",
"tzeRnbd77HU",
"VkIAbDIVJCA",
"ksJ6kwTe9wM"
]
}
},
{
"Title": "Rawa Island",
"Latitude": "2.520278",
"Longitude": "103.975833",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": { "YouTubeVideoID": "Kx0dUWaALKo" }
},
{
"Title": "Perhentian Island",
"Latitude": "5.903788",
"Longitude": "102.753737",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": {
"YouTubeVideoID": [
"ZpcdGk5Ee0w",
"TQTDOGpflZY"
]
}
},
{
"Title": "Sabah Marine Park",
"Latitude": "4.623326",
"Longitude": "118.719800",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": { "YouTubeVideoID": "VCDTEKOqpKg" }
}
]
}
}
}
}
here my function where i am retriving latitude and lognitutde from above json file
<script type="text/javascript">
$.getJSON('json/explore.json', function(data) {
$.each(data, function(key, val) {
for (var i = 0; i < val.Explore.IslandLife.TourismLocation.length; i++) {
PlotMarker(val.Explore.IslandLife.TourismLocation[i].Latitude, val.Explore.IslandLife.TourismLocation[i].Longitude);
}
});
});
function PlotMarker(lat, lang) {
var mapProp = {
center: new google.maps.LatLng(lat, lang),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("gmap"), mapProp);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat, lang),
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', PlotMarker);
</script>
<body>
<div id="gmap" style="width: 800px; height:500px;"></div>
</body>
How to show multiple markers on map ???