Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌地图热图未显示_Javascript_Google Maps - Fatal编程技术网

Javascript 谷歌地图热图未显示

Javascript 谷歌地图热图未显示,javascript,google-maps,Javascript,Google Maps,我试图创建一个简单的热图示例,但没有显示任何内容。我没有任何错误,也不确定问题出在哪里。如果有人能告诉我他们看到了什么,我会很感激的 <!DOCTYPE html> <html> <head> <title>HeatMap</title> <script src="https://maps.googleapis.com/maps/api/js?key=MYKEY&sensor=false&libr

我试图创建一个简单的热图示例,但没有显示任何内容。我没有任何错误,也不确定问题出在哪里。如果有人能告诉我他们看到了什么,我会很感激的

<!DOCTYPE html>
<html>
<head>
<title>HeatMap</title>
 <script
        src="https://maps.googleapis.com/maps/api/js?key=MYKEY&sensor=false&libraries=visualization"
        type="text/javascript"></script>
<script>
var map;
var heatmapData = [
new google.maps.LatLng(37.782, -122.447),
new google.maps.LatLng(36.778261, -119.417932),
new google.maps.LatLng(-37.814107, 144.96328),
new google.maps.LatLng(33.867487, 151.20699),
{ location: new google.maps.LatLng(40.416775, -3.70379), weight: 6 },
{ location: new google.maps.LatLng(41.385064, 2.173403), weight: 2 },
{ location: new google.maps.LatLng(52.130661, -3.783712), weight: 2 },
{ location: new google.maps.LatLng(55.378051, -3.435973), weight: 8 },
{ location: new google.maps.LatLng(-40.900557, 174.885971), weight: 6 },
{ location: new google.maps.LatLng(40.714353, -74.005973), weight: 6 }
];
function initializeMap() {
var myMapOptions = {
zoom: 4,
center: new google.maps.LatLng(40.785611, -25.94700),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById(‘map’),myMapOptions);
var heatmap = new google.maps.visualization.HeatmapLayer({
data: heatmapData,
dissipating: false,
map: map
});
}
google.maps.event.addDomListener(window, ‘load’, initializeMap);
</script>
</head>
<body>
<div id="map" style="width: 1000px; height: 800px;"></div>
</body>
</html>

您的代码中有非法字符。Chrome控制台报告:未捕获SyntaxError:第28行的意外令牌非法。如果我用一句话来代替它们,它对我来说是有效的

两个变化:

google.maps.event.AddDomainListenerWindow,“加载”,初始化映射;->”装载 map=new google.maps.Mapdocument.getElementById'map',myMapOptions;->'地图'
<!DOCTYPE html>
<html>
<head>
<title>HeatMap</title>
 <script
        src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=visualization"
        type="text/javascript"></script>
<script>
var map;
var heatmapData = [
new google.maps.LatLng(37.782, -122.447),
new google.maps.LatLng(36.778261, -119.417932),
new google.maps.LatLng(-37.814107, 144.96328),
new google.maps.LatLng(33.867487, 151.20699),
{ location: new google.maps.LatLng(40.416775, -3.70379), weight: 6 },
{ location: new google.maps.LatLng(41.385064, 2.173403), weight: 2 },
{ location: new google.maps.LatLng(52.130661, -3.783712), weight: 2 },
{ location: new google.maps.LatLng(55.378051, -3.435973), weight: 8 },
{ location: new google.maps.LatLng(-40.900557, 174.885971), weight: 6 },
{ location: new google.maps.LatLng(40.714353, -74.005973), weight: 6 }
];
function initializeMap() {
var myMapOptions = {
zoom: 4,
center: new google.maps.LatLng(40.785611, -25.94700),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'),myMapOptions);
var heatmap = new google.maps.visualization.HeatmapLayer({
data: heatmapData,
dissipating: false,
map: map
});
}
google.maps.event.addDomListener(window, 'load', initializeMap);
</script>
</head>
<body>
<div id="map" style="width: 600px; height: 500px;"></div>
</body>
</html>