希望您能帮助我使用以下代码。我有问题让热图加载到Chrome中,但它确实在IE中加载(刷新后)希望你可以提供我/一些指针,以检查我刚刚谷歌地图,JS和JSON: - )
谢谢你! <!DOCTYPE html>
<html>
<head>
<title>Phone Home</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script type="text/javascript" src="../src/markerclusterer.js"></script>
<script type="text/javascript" src="../src/jquery.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=geometry,visualization&key=****"></script>
<script>
var map,heatmap;
var markers = [];
var xmlhttp = new XMLHttpRequest();
var url = "../src/et.json";
function initialize() {
// Create a simple map.
map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 3,
center: new google.maps.LatLng(0,0)
});
getMarkers(url);
heatmap = new google.maps.visualization.HeatmapLayer({
data: markers
});
heatmap.setMap(map);
}
function getMarkers(url){
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
loadMarkers(myArr);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function loadMarkers(arr) {
var out = "";
var i;
for(i = 0; i < arr.length; i++) {
var latLng = new google.maps.LatLng(arr[i].latitude,arr[i].longitude);
var marker = new google.maps.Marker({
position: latLng
});
markers.push(latLng);
}
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>