我想从本地数据存储在geoJson文件中创建Bing地图的热图,但我不能让它工作......奇怪的是,如果完全相同的文件在线是绝对没有问题的。这里是我正在使用的脚本:如何使用本地json文件创建热图(Bing地图)?
<script type='text/javascript'>
function GetMap() {
var map = new Microsoft.Maps.Map('#myMap', {
credentials: 'my_bing_maps_key_(not_forgotten)',
zoom: 4
});
//Load the GeoJSON and HeatMap modules
Microsoft.Maps.loadModule(['Microsoft.Maps.GeoJson', 'Microsoft.Maps.HeatMap'], function() {
// Earthquake data in the past 30 days from usgs.gov
Microsoft.Maps.GeoJson.readFromUrl('data/all_month.geojson', function (shapes) {
var heatMap = new Microsoft.Maps.HeatMapLayer(shapes, { radius: 5 });
map.layers.insert(heatMap);
});
});
}
</script>
有了它,没有热图层出现。但是当我简单地用它代替时,一切都很完美:
<script type='text/javascript'>
function GetMap() {
var map = new Microsoft.Maps.Map('#myMap', {
credentials: 'my_bing_maps_key_(not_forgotten)',
zoom: 4
});
//Load the GeoJSON and HeatMap modules
Microsoft.Maps.loadModule(['Microsoft.Maps.GeoJson', 'Microsoft.Maps.HeatMap'], function() {
// Earthquake data in the past 30 days from usgs.gov
Microsoft.Maps.GeoJson.readFromUrl('http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson', function (shapes) {
var heatMap = new Microsoft.Maps.HeatMapLayer(shapes, { radius: 5 });
map.layers.insert(heatMap);
});
});
}
</script>
我真的不明白这里有什么问题。
非常感谢!
我编辑了你的问题,使其更清晰一些。 – byxor