8

[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.

geocodezip
  • 158,664
  • 13
  • 220
  • 245
Sulliwane
  • 410
  • 6
  • 16
  • Wow, I can't tell what was the reason of the problem (mismatching maps) but both are at this moment the same. Maybe it takes some while for google maps to update the KML link...if someone has a rational explanation... – Sulliwane Aug 29 '12 at 12:41

2 Answers2

21

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();
geocodezip
  • 158,664
  • 13
  • 220
  • 245
1

Or you can simplify it even further and use:

var URL = '[your kml url here]&ver=' + Date.now();

var georssLayer = new google.maps.KmlLayer(URL);

MistyDawn
  • 856
  • 8
  • 9