shramov / leaflet-plugins

Plugins for Leaflet library
http://psha.org.ru/b/leaflet-plugins.html
MIT License
725 stars 288 forks source link

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

Open ismail44 opened 8 years ago

ismail44 commented 8 years ago

(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.

brunob commented 8 years ago

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

ismail44 commented 8 years ago

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 notifications@github.com 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 commented 8 years ago

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 bill.oberacker@gmail.com 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 notifications@github.com 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

brunob commented 8 years ago

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.

ismail44 commented 8 years ago

Thanks!

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

brunob commented 8 years ago

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.

ismail44 commented 8 years ago

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.

brunob commented 8 years ago

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

ismail44 commented 8 years ago

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 notifications@github.com 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 commented 8 years ago

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 bill.oberacker@gmail.com 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 notifications@github.com 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

brunob commented 8 years ago

Still no map...

ismail44 commented 8 years ago

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 notifications@github.com 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 commented 8 years ago

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/

brentfraser commented 8 years ago

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...