[KML For Google Maps Mobile] Unabke to remove KML

Forge Component
Published on 2019-03-20 by Pedro Costa
3 votes
Published on 2019-03-20 by Pedro Costa

We have been trying a couple days to get KMLs working with our mobile application.

Currently we are able to dynamically generate KMLs and show them on the map. However we seem unable to get them removed. We do notice that when trying the Subway kml file it looks like a "shadow" of the subway is created that then gets removed. But the original line remains.

When trying to use markers we concluded the same thing. After breaking de ZipFile.js we were able to show and remove the KML layers. However instead of the default Red Google markers we get Blue ones.

So what we suspect is happening is that the component uses a google api to create a "google clone" of the points/lines etc and tries to bind them to the original points. But that this bind for some reason fails (The ZipFile js being last updated 2012 would enforce that thought, we also suspect that the other JS files have not been updated for quite some time cuasing a disconnect with the current GoogleMaps version)

Have you experienced the same thing?

Hi Eric,

Let me see if I understood your problem. You are able to add the KML with its default style (defined in the file), but you can't choose its colors, is it correct? Can you provide me prints?

Hi Isabella,

No the styling is not the problem. The blue and red markers were default markers when no marker is specified
It's hard to show the problem. Let me see if I can explain again.

When displaying a KMZ or ZIP on the map generated/hosted from our own server (hosting from an external server gives a CORS error but then removing works, pointing towards our suspicion being right) it seems like it gets displayed twice. Once as a KML with KMLid and once as part of Google maps without KMLid (and slightly scaled down).

When using the remove action the KML one gets delted while the Google maps "clone" remains.

Using the sample KML this can be seen by the thickness of the lines. This is after loading the KML:

and this is after removing the KML:

if you look at the thickness of the lines I hope it's clear what i mean. This also happens with styled markers (big marker gets removed showing a scaled down marker beneath)

that's why we suspect that google maps tries to create a "clone" of the element and then bind it to the layer. However for some reason it fails to bind it properly.
Currently we have the removing working, but we achieved this by accident by breaking the Zip.js which obviously should not be done.


Ok Eric, this is happening because we add the kml twice.

The first adds kml with its default style.

The second will use a third parser to render kml applying the styles defined in PlacemarkList

Choose one for using and comment the other

Tell me later if it worked

Edit: You can find this code in osKMLGoogleMap script


Thank you Isabella, that indeed worked!

Is there a reason why you add it twice?
perhaps it would be an option to have a parameter choose between which one?