谷歌地图和javascript 如何动态更新(重新显示)自定义地图图块?
我有一个数据库,其中存储了数千个(纬度,经度)点。使用切片服务器将这些点绘制到地图中。这样的图块服务器首先为每个图块计算落在图块内的点,然后绘制每个点(在坐标转换之后)。我的 Javascript 如下所示:
var overlayMaps = [{
getTileUrl: function(coord, zoom) {
return "tileserver.php?x="+coord.x+"&y="+coord.y+"&z="+zoom+"&g=1";
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
opacity: 1.0
}];
var overlayMap = new google.maps.ImageMapType(overlayMaps[0]);
map.overlayMapTypes.setAt(0,overlayMap);
现在,我每 5 秒动态地将新记录添加到数据库中,并且我希望每 5 秒更新(重新计算和重新显示)相应的图块。
如何触发我的图块服务器每 5 秒重新计算视口的图块?
补充:图块每 5 秒更新一次,没有问题,但现在的主要问题是在地图上重新显示它们...
提前感谢...
I have a database with thousands of (latitude,longitude) points stored in it. Those points are plotted into a map using a tile server. Such tile server first computes, for each tile, the points that fall inside the tile, and then draws every point(after coordinates conversion). My Javascript looks as follows:
var overlayMaps = [{
getTileUrl: function(coord, zoom) {
return "tileserver.php?x="+coord.x+"&y="+coord.y+"&z="+zoom+"&g=1";
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
opacity: 1.0
}];
var overlayMap = new google.maps.ImageMapType(overlayMaps[0]);
map.overlayMapTypes.setAt(0,overlayMap);
Now, I am dynamically adding new records to the database every 5 seconds, and I want the respective tiles to be updated (re-computed and re-displayed) every 5 seconds.
How could I trigger my tile server to re-compute tiles of the viewport every 5 seconds ?
Added: The tiles are updated every 5 seconds without problems, but the main problem now is re-displaying them on the map...
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
图块是图像,您不可能知道其中哪一个可能会更改。此外,您无法刷新单个图块,而是刷新整个视口。您所能做的就是动态地提供图块,每次视口更改或不缓存图块图像,所以它们总是会变化。为此,您可以将时间标志或随机数放入您的图块 URL 代码中,如下所示。
此致
Tiles are images,you can't possibly know which one of these may change.Also,you can't refresh single tiles but entire viewport.All you can do,serving your tiles dynamically,each time viewport changes or not tile images not cached,so they always change.For this,you can put a time flag or random number into your tile url code like this.
Best Regards