0
votes

My website (www.boatingtrax.com) presents maps from google earth and google maps. I prepare the kml files and load the file to my server. I put links to the various kml files on my site (https://www.boatingtrax.com/notices-to-mariners/news-south-wales-notices-mariners/) and google earth formats are generated. NICE!

I update the kml files daily and a new google earth map is generated.

Google Maps is different. I can produce a google map using the kml file and embed the map on site or share the link Both work well. Also nice!

But I have to do that every time I change the kml files (which is daily). Painful!

Could anyone point me to a process so that I can keep Google Maps updated automatically?

Any help appreciated.

1

1 Answers

1
votes

If I understand correctly, your issue is that every time you upload a new KML, it has a new filename, and therefore you need to change your Maps API code to point at the new file each time?

If so, you should probably check out KML Network Links. A KML NetworkLink is a small KML file that contains a pointer to another KML file.

In your case, what I would do is create one NetworkLink KML with a static filename, which always points at your latest data KML. Have your Maps API code load the NetworkLink file, and it will show the target KML. Each time you add a new data KML, you just have to upload a new copy of the NetworkLink KML (with the same filename), which points at the new data KML.

For details on KML Network Links, see these resources:

A few things to note... Maps API has some caching of KML files built in, so there may be a delay (minutes?) from when you update the NetworkLink file to when you see the new data on your map. Google Earth supports long strings of nested NetworkLinks, but Maps will only follow a limited number of NetworkLinks (10, I think?), so be careful if you go down the road of nesting them. Also, Google Maps API does not support all the KML elements which Earth does... details here.