javascript 更新热图数据,简单的google HeatMap
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13479514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Updating heatmap data, simple google HeatMap
提问by Yonahs
I've built this android app to collect longitude,latitude, and phone signals for my class project. My objective is to port this info to a simple heatmap webpage. My question is what's the best way to update my heatmap data variable in this example:
我已经构建了这个 android 应用程序来为我的课堂项目收集经度、纬度和电话信号。我的目标是将此信息移植到一个简单的热图网页。我的问题是在此示例中更新我的热图数据变量的最佳方法是什么:
https://google-developers.appspot.com/maps/documentation/javascript/examples/layer-heatmap
https://google-developers.appspot.com/maps/documentation/javascript/examples/layer-heatmap
This variable in particular:
特别是这个变量:
var taxiData = [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586), ...
];
I'm open to all suggestions, I'm pretty much a novice with web development.
我对所有建议持开放态度,我几乎是网络开发的新手。
回答by Bubbles
Google maps makes this very straightforward. You might notice later on in this example, taxiData is loaded into a specific google array here -
谷歌地图使这非常简单。您稍后可能会注意到,在此示例中,taxiData 被加载到此处的特定 google 数组中 -
pointArray = new google.maps.MVCArray(taxiData);
And then this is put into the map as a heatmap here:
然后将其作为热图放入地图中:
heatmap = new google.maps.visualization.HeatmapLayer({
data: pointArray
});
heatmap.setMap(map);
The MVCArray can be updated, and the map will automatically update. So, if you need to add a new LatLng to your heatmap, simply put:
MVCArray 可以更新,地图会自动更新。因此,如果您需要向热图中添加新的 LatLng,只需输入:
pointArray.push(new LatLng(<coordinates>));
And the map will update.
并且地图会更新。