我可以使用geojson将数据绘制到谷歌地图上。我现在想每隔10秒刷新一次标记。我怎样才能做到这一点?在我的例子中,json文件将在我的本地服务器上刷新。我如何更改相同标记的属性/位置?使用Geojson刷新Google地图图层
<!DOCTYPE html>
<html>
<head>
<style>
html, body, #map {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
var layer1;
var layer2;
function initialize() {
var mapOptions = {
zoom: 11,
center: new google.maps.LatLng(23.0171240, 72.5330533),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map"), mapOptions);
layer1 = map.data.loadGeoJson('http://localhost/envitia.its.webclient/myjson.json');
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map">
</div>
</body>
</html>
谢谢你的作品,但遗留在地图上的旧标记。我想完全重新加载图层,以便删除旧标记。 – user2837961
将标记放入数组中。然后在添加新标记之前清除数组中的标记。 Google的API Doc网站上有样本。 – Todd
但是我如何在使用loadGeoJson函数时获得标记列表?您能否给我一下Google API Doc站点示例的链接? – user2837961