I'm creating a car tracking app and I'm having a problem, I'm trying to make the map update dynamically without the need to update the page manually, this page receives the location through a .json file in the code I'm calling a file, but the information will come through a Web Service where it receives location information through GPS, would anyone have any idea how I can leave this dynamic page?
<metahttp-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>--><scriptsrc="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/normalize.css">
<link rel="stylesheet" type="text/css" href="css/result-light.css">
<style type="text/css">
#map_canvas { width: 1000px; height: 600px; }
</style>
<title></title>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
var gMapsLoaded = false;
window.gMapsCallback = function(){
gMapsLoaded = true;
$(window).trigger('gMapsLoaded');
}
window.loadGoogleMaps = function(){
if(gMapsLoaded) return window.gMapsCallback();
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src","http://maps.google.com/maps/api/js?sensor=false&callback=gMapsCallback");
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
}
$(document).ready(function(){
function initialize(){
//Aqui cria a varivel para o mapa
var myLatLng = {lat: -23.001066, lng: -43.421180};
var pos = {lat: -23.001271, lng: -43.329061};
var image = 'img/car2.png';
var mapOptions = {
zoom: 15,
center: new google.maps.LatLng(-23.001066, -43.421180), //-23.001066, -43.421180
mapTypeId: google.maps.MapTypeId.ROADMAP};
map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
$.getJSON('igreja.json', function(data) { //igreja.json //endereco1.json
//var output="<ul>";
var mark;
var infowindow = new google.maps.InfoWindow;
for (var i in data) {
mark = new google.maps.Marker({
position: new google.maps.LatLng(data[i].latitude, data[i].longitude),
map: map,
icon: image
});
mark.addListener('click', function() {
map.setZoom(15);
map.setCenter(mark.getPosition());
infowindow.setContent(data[i].nome);//data[i].latitude, data[i].longitude
infowindow.open(map, mark);
});
}
});
}
$(window).bind('gMapsLoaded', initialize);
window.loadGoogleMaps();
});
});//]]>
</script>
</head>
<body>
<div id="map_canvas"></div>
<div id="debug"></div>
</body>