Search code examples
javascriptgoogle-maps-api-3kml

Google Map API with KmlLayer


I'm using Google Map API with KMLLayer.

I create and use KML File online with google map.

But my KML File not refresh when I'm modify that.

urlPolygon is from Database ( mid of KML Url)

This is my code

var urlPolygon = response.urlPolygon;

                    var map = new google.maps.Map(document.getElementById('mapTracking'), {
                        zoom: 14,
                        //center: new google.maps.LatLng(13.756738, 100.501874), // DEFAULT BANGKOK
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        minZoom: 10,
                        maxZoom: 17,
                        zoomControl: false,
                        mapTypeControl: false,
                        scaleControl: false,
                        streetViewControl: false,
                        rotateControl: false,
                    });

                    var url = "";

                        url = "http://www.google.com/maps/d/kml?forcekml=1&mid=" + urlPolygon;


                    var georssLayer = new google.maps.KmlLayer({
                        url: url
                    });
                    georssLayer.setMap(map);

But when I Export KML File with from Google. That file has been updated.

I don't know why. Thank you.


Solution

  • KmlLayer URLs are cached on Google's server when they are rendered. The API has no way of knowing the content has changed unless you request the layer again with a different URL (i.e. add a cache busting parameter)