Custom Modules and the Google Maps API KML Layer

The website I have just migrated to Treepl displays Google Map images and GPS Traces (KML Data) using the Maps Javascript API.

Since migrating from BC to Treepl the KML data does not display. The code generated by the custom module is correct.

I have built a test page that displays a Map & should display a Trace.

The Trace will not load the KML Data from the Treepl version.

But if I load the KML Data off the old Business Catalyst site the Trace is displayed.

Is anyone else displaying KML/KMZ layer data on Google map images using the Google map APIs & if so, how did you get around this problem?

This works:

var ctaLayer = new google.maps.KmlLayer({
  url: 'https://dingogap.businesscatalyst.com/media/kmls/20170424-splendourRock.kml',
  map: map
});

This does not:

var ctaLayer = new google.maps.KmlLayer({
  url: 'https://dingogap.net.au/images/kmls/20170424-splendourRock.kml',
  map: map
});

The only difference is the file location.

Is this a permission problem?

Comments or suggestions would be appreciated.

Would it be the domain authorisation in the Google API credentials?
You may need to add the sites domain now in place of the businesscatalyst domain.

No - the satellite map renders correctly on the Treepl version of the site. It’s the path to the .kml file that isn’t being handled correctly.

When the site went live the Google Maps authorisation went with it (same ID). Maps no longer render on the BC version of the site.

Maps render on the Treepl version of the site but .kmls don’t load from the Treepl site. The .kmls will load from the BC site.

If you paste the BC Url into a browser it downloads the file automatically.

If you paste the Treepl Url into a browser it returns http error 404.

Ah, I see. According to the docs here:
https://docs.treepl.co/documentation_group/about-treepl-cms/limits-restrictions#secAllowedFileTypes
That file type is not supported.
Perhaps it can be hosted elsewhere temporarily and contact support to see if it can be added.

Thanks Adam. That would explain it.

I’d be surprised if this is is the only site that wants to use the Google Maps API.

I logged an incident about this on Friday. I was told it would take 2 business days for a reply with a solution.

Just thinking out loud… could you try changing the file extension and the reference just to .xml?
I wonder if the API would still accept it?

It’s a good idea @Adam.Wilson. KMLs are an XML format. Changing the file extension to XML is accepted but it isn’t handled correctly by the API. The API treats some data (not sure which part yet) as track points & draws a horizontal trace out past New Zealand. That is almost 20º Longitude out and doesn’t happen when processed as a KML. I’ve even exported the KML Data out of Google Earth (compressed XML data) instead of OziExplorer (properly formatted XLM). Google Earth is quite particular about the correctness of the data it consumes to render traces.

Hmmm, that’s a bugga.
Hosting the file externally should work for the short term wouldn’t it?
Even on some cloud storage perhaps.

It certainly does - currently loading KMLS from the original BC site in the example I provided to Treepl Support.

The original BC Site will still be there for a few weeks.

I have placed the .kml files on GitHub.

I have commented out the code that reads the .kmls from the Treepl Site, added a couple of extra lines to parse the Custom Module .kml path and build the path to file stored on GitHub.

It works.

That way I don’t have to edit data when Treepl finally supports .kmls. I only have to delete 3 lines of code & remove some comments.

Just have to remember to store the .kml file in 2 locations.

1 Like

Hey @peter.medbury, just letting you know .kml files are now support with v4.3 release :slight_smile:

It’s working well thanks @Adam.Wilson.