重新加载页面时,Kml图层不会更新 [英] Kml layers doesn't update when reloading the page

查看:80
本文介绍了重新加载页面时,Kml图层不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎问题来自谷歌地图,需要一些时间来更新KML链接...我不确定,但最终,它的工作原理... [/编辑]



我在此网站上嵌入现有的公开Goog​​le地图: http:// www。 ridetheflavour.fr



以下是公共地图的链接: https://maps.google.fr/maps/ms?msa=0&msid=211027213468691902621.0004c8616605648d245b2



如您所见,网站嵌入式地图的标记与公开的Google地图标记不匹配。看起来这不是浏览器缓存的问题......



以下是我使用的JavaScript片段(Google map API V3):

  var mapOptions = {
center:new google.maps.LatLng(24.797409,-5.449219),
zoom:3,
mapTypeId:google.maps.MapTypeId.TERRAIN,
overviewMapControl:false,
streetViewControl:false
};
var map = new google.maps.Map(document.getElementById(map_canvas),
mapOptions);
var georssLayer = new google.maps.KmlLayer('https://maps.google.fr/maps/ms?ie=UTF8&authuser=0&msa=0&output=kml&msid=211027213468691902621.0004c8616605648d245b2' );
georssLayer.setMap(map);

任何帮助将不胜感激。

解决方案

Google的服务器缓存KML内容一段时间。要强制更新呈现的KML,请在URL中添加缓存清除参数。我通常使用日期/时间的函数,如果我需要以编程方式执行它,或者如果它只是一次性编辑手册?a = 0并且随着我进行更改而增加它。



类似这样(如果URL中没有其他查询参数):

  var URL = filename +?dummy =+(new Date())。getTime(); 


[EDIT] it seems the problem comes from google maps which takes some time to update the KML link...I'm not sure, but in the end, it works...[/EDIT]

I embedded an existing public google map on this website : http://www.ridetheflavour.fr

Here is the link of the public map : https://maps.google.fr/maps/ms?msa=0&msid=211027213468691902621.0004c8616605648d245b2

As you can see, the markers of the website's embedded map don't match the public google map markers. It seems it's not a matter of browser cache...

Here is the javascript snippet i'm using (Google map API V3) :

var mapOptions = {
          center: new google.maps.LatLng(24.797409,-5.449219),
          zoom: 3,
          mapTypeId: google.maps.MapTypeId.TERRAIN,
          overviewMapControl: false,
          streetViewControl: false
        };
var map = new google.maps.Map(document.getElementById("map_canvas"),
            mapOptions);
var georssLayer = new google.maps.KmlLayer('https://maps.google.fr/maps/ms?ie=UTF8&authuser=0&msa=0&output=kml&msid=211027213468691902621.0004c8616605648d245b2');
georssLayer.setMap(map);

Any help would be greatly appreciated.

解决方案

Google's servers cache the KML content for some period of time. To force the rendered KML to update, add a cache busting parameter to the URL. I usually use a function of the date/time if I need to do it programmatically, or if it is just a one time edit a manual ?a=0 and incrementing that as I make changes works.

Something like this (if you don't have any other query parameters in the URL):

 var URL = filename+"?dummy="+(new Date()).getTime();

这篇关于重新加载页面时,Kml图层不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆