Raruto / leaflet-kmz

A KMZ file loader for Leaflet Maps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing icons when loading plain kml

bugfindr opened this issue · comments

In latest version, facing issue with Icon property in KMZLayer.js file.

image

image

That's says undefined icon property. Please help on the same.

Hi Bugfindr,
there is probably something wrong with your kmz file (e.g. missing or incorrect <Icon> tags).

To debug that you can use the following snippet:

var kmz = L.kmzLayer('demo.kmz', {
  geometryToLayer: function(data) {
    console.log(data);
    return L.geoJson(data);
  }
}).addTo(map);

Anyway, it would be better if you could also provide an example file ...

Have a nice day,
Raruto

Hi Raruto,
Thank you very much for quick response.

I just used above code snippet and I don't see above mentioned error. but If I remove geometryToLayer then I will see again above error.
image

And major issue If I use geometryToLayer then I am facing "KMZ style" issue. Looks like all geometry and icons appearance in default style (blue color). However my KMZ has different color and icons. And that KMZ working fine with google earth and google Map.

I am attaching a minor KMZ for your test including output screenshots at my end.

Also you will notice on click popup also not appearing on map. Thank You.

demo-test.zip

KMZ output on Map.
image

KMZ Output on Google Earth.
image

If I use geometryToLayer then I am facing "KMZ style" issue. Looks like all geometry and icons appearance in default style (blue color). However my KMZ has different color and icons. And that KMZ working fine with google earth and google Map.

That happens because the geometryToLayer option overrides the following default styling function:

_geometryToLayer: function(data) {

For further details, here you can see a more in-depth example: leaflet-kmz_gridlayer.html.

I am attaching a minor KMZ for your test including output screenshots at my end.

Thanks for the demo file, your problem was related to the fact that the file is not actually a "zipped" folder (but a simple "kml" text file).

Take a look at version 1.0.5 and then let me know if it works.

Happy testing,
Raruto

I just saw leaflet-kmz_gridlayer.html file. but there's no way to apply KMZ/KML direct to map without overrides?

I just saw leaflet-kmz_gridlayer.html file. but there's no way to apply KMZ/KML direct to map without overrides?

I don't think I understand well, however, have you tried (with version 1.0.5) to simply doing so?

var kmz = L.kmzLayer('demo.kmz').addTo(map);

Tested with 1.0.5 and getting error as mentioned below.

image

@Raruto Never mind. Looks like your change works now. I will back to you If I will find something.

Thank you very much!