leaflet-plugins icon indicating copy to clipboard operation
leaflet-plugins copied to clipboard

A possible issue with Multi-geometries and Name and Description inside KML Plugin?

Open ismail44 opened this issue 8 years ago • 14 comments

(Using KML Plugin version from Master)

We have an internal service that creates a KML which we try to display on our map. This KML has a name and description element inside of a Placemark that is defined as a Multigeometry. It seems that inside the parsePlacemark it recurses back into the parsePlacemark function with the "Multi-type" elements. These elements, subsequently don't have the Name and/or Description fields.

Is this non-standardized KML which I just have to account for, or is this an issue with the KML plugin?

I do not have a KML sample which I can post here as it's on a closed system. I could, however, try to fashion a sample, but basically it's just a <Placemark> element with <Name> and <Description> and <Multigeometry> and children (at the same level).

Thanks.

ismail44 avatar Mar 28 '16 12:03 ismail44

You should have a look at KML specs and provide a jsfiddle reproducing the bug ;)

brunob avatar Mar 28 '16 13:03 brunob

I looked at the KML specs and while the words appear to be in English, I don't think they are. I'll see if I can find a few minutes to throw up a fiddle. I was more curious than anything. And, like I said... the KML we have is on a closed network that I CANNOT make public, so it's going to be very difficult for me to do this. But, I'll see what I can do.

On Mon, Mar 28, 2016 at 9:42 AM, b_b [email protected] wrote:

You should have a look at KML specs and provide a jsfiddle reproducing the bug ;)

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/shramov/leaflet-plugins/issues/215#issuecomment-202398587

ismail44 avatar Mar 28 '16 13:03 ismail44

Also, is there a reason the description is not shown if there's no name for the Placemark?

On Mon, Mar 28, 2016 at 9:45 AM, Bill Oberacker [email protected] wrote:

I looked at the KML specs and while the words appear to be in English, I don't think they are. I'll see if I can find a few minutes to throw up a fiddle. I was more curious than anything. And, like I said... the KML we have is on a closed network that I CANNOT make public, so it's going to be very difficult for me to do this. But, I'll see what I can do.

On Mon, Mar 28, 2016 at 9:42 AM, b_b [email protected] wrote:

You should have a look at KML specs and provide a jsfiddle reproducing the bug ;)

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/shramov/leaflet-plugins/issues/215#issuecomment-202398587

ismail44 avatar Mar 28 '16 13:03 ismail44

Also, is there a reason the description is not shown if there's no name for the Placemark?

Mainly historical reason, see :

https://github.com/shramov/leaflet-plugins/blob/master/layer/vector/KML.js#L289

Maybe we can change this, feel free to provide a pull request for that.

brunob avatar Mar 28 '16 14:03 brunob

Thanks!

I am trying to create a fiddle for the original issue... how do I add your KML plugin? Is there a CDN link?

ismail44 avatar Mar 28 '16 15:03 ismail44

No CDN for now, there is a PR for that on cdnjs/cdnjs#6137 but it's done yet, so you have to use direct link to raw file from here.

brunob avatar Mar 28 '16 15:03 brunob

Here is the fiddle for the initial question:

http://fiddle.jshell.net/kybp2dcd/32/

The KML with name and description OUTSIDE of the multigeometry is at:

https://gist.githubusercontent.com/ismail44/880dfedaed05186f14ff/raw/58a6c986cc50bb21a9eaea5d5f2d534fe0fed234/gistfile1.txt

When you try to click on the marker (or the polygon) you don't see the name or description.

Thanks.

ismail44 avatar Mar 28 '16 15:03 ismail44

Hmm strange but your fiddle doesn't show any map... am i missing something ?

brunob avatar Mar 28 '16 15:03 brunob

For some reason there's an SSL error on the site for the leaflet code. Let me see what I can do.

On Mon, Mar 28, 2016 at 11:53 AM, b_b [email protected] wrote:

Hmm strange but your fiddle doesn't show any map... am i missing something ?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/shramov/leaflet-plugins/issues/215#issuecomment-202453731

ismail44 avatar Mar 28 '16 16:03 ismail44

I removed the "https" bits... try this link:

https://fiddle.jshell.net/kybp2dcd/38/

On Mon, Mar 28, 2016 at 12:00 PM, Bill Oberacker [email protected] wrote:

For some reason there's an SSL error on the site for the leaflet code. Let me see what I can do.

On Mon, Mar 28, 2016 at 11:53 AM, b_b [email protected] wrote:

Hmm strange but your fiddle doesn't show any map... am i missing something ?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/shramov/leaflet-plugins/issues/215#issuecomment-202453731

ismail44 avatar Mar 28 '16 16:03 ismail44

Still no map...

brunob avatar Mar 28 '16 17:03 brunob

HMMM

Then I don't really know what to do. Is there a fiddle you use when demoing (with leaflet v.0.7.7) that I can clone?

On Mon, Mar 28, 2016 at 1:57 PM, b_b [email protected] wrote:

Still no map...

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/shramov/leaflet-plugins/issues/215#issuecomment-202508135

ismail44 avatar Mar 28 '16 18:03 ismail44

Can you verify that when you go to the fiddle you are connecting to fiddle.net over the standard http port and not the https port? (Meaning, make sure it's http and not https). I just realized I copied the wrong address... try this one:

http://fiddle.jshell.net/kybp2dcd/38/

ismail44 avatar Mar 29 '16 23:03 ismail44

I have the same problem. I'm using the url: http://gis.hamweather.net/kml/hwadv_all.kml fi you want to reproduce the problem. So I hacked the parsePlacemark function to remove the recursion (after line 247):

        var layers = [];

        var multi = ['MultiGeometry', 'MultiTrack', 'gx:MultiTrack'];
        for (h in multi) {
            el = place.getElementsByTagName(multi[h]);
            for (i = 0; i < el.length; i++) {
//              return this.parsePlacemark(el[i], xml, style, opts);
                var parse = ['LineString', 'Polygon', 'Point', 'Track', 'gx:Track'];
                for (j in parse) {
                    var tag = parse[j];
                    el = place.getElementsByTagName(tag);
                    for (i = 0; i < el.length; i++) {
                        var l = this['parse' + tag.replace(/gx:/, '')](el[i], xml, opts);
                        if (l) { layers.push(l); }
                    }
                }
            }
        }

I'm not sure if this conforms to the KML spec...

brentfraser avatar Jul 01 '16 23:07 brentfraser