Flexberry / Leaflet-WFST

OGC WFS-T client layer for Leaflet.
http://flexberry.github.io/Leaflet-WFST/
MIT License
151 stars 50 forks source link

Cannot display layer of type MultiLineString #29

Closed ismail44 closed 8 years ago

ismail44 commented 8 years ago

I am using leaflet 0.7.7.

I am grabbing the layer osm:ne_110m_admin_0_boundary_lines_land from http://demo.opengeo.org/geoserver/wfs:

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" maxFeatures="2" outputFormat="text/xml; subtype=gml/3.1.1"><wfs:Query typeName="osm:ne_110m_admin_0_boundary_lines_land" srsName="EPSG:4326"/></wfs:GetFeature>

The type that's coming back for each FeatureMember is a MultiLineString. For some reason, Leaflet isn't drawing the layer(s) because it cannot parse the list of LatLngs from the XML being returned. From what I can see this the element that contains the coords:

`

-62.84648000000001 -22.034990000000004 -63.98684000000001 -21.99363 -64.37702 -22.79811 -64.96488000000001 -22.07584 -66.27334 -21.83231 -67.10668 -22.73592 -67.82818 -22.8729 -68.21991 -21.49434 -68.75717 -20.372670000000003 -68.44222 -19.40508 -68.96682 -18.98166 -69.10026 -18.26012 -69.59042 -17.58002 -68.95965000000001 -16.500680000000003 -69.38977000000001 -15.660120000000001 -69.16036 -15.32395 -69.33953000000001 -14.9532 -68.94888 -14.45364 -68.92923 -13.60267 -68.88007 -12.899720000000002 -68.66509 -12.56131 -69.52969 -10.9517 -68.78616 -11.03636 -68.27124 -11.014500000000002 -68.04819 -10.712069999999999 -67.1738 -10.30681 -66.64691 -9.9313 -65.33844 -9.76197 -65.44484 -10.511420000000001 -65.32189 -10.89584 -65.40227 -11.56629 -64.31635 -12.462000000000002 -63.1965 -12.627040000000001 -62.803050000000006 -13.000670000000001 -62.12707 -13.198770000000001 -61.71322 -13.48921 -61.084120000000006 -13.47939 -60.50331 -13.77597 -60.459199999999996 -14.35399 -60.26433 -14.64596 -60.25115 -15.07722 -60.54296 -15.093910000000001 -60.15839 -16.25827 -58.24121 -16.29956 -58.38806 -16.87711 -58.28081 -17.27169 -57.734550000000006 -17.55249 -57.498380000000004 -18.17419 -57.676 -18.961850000000002 -57.95 -19.400000000000002 -57.85379 -19.970010000000002 -58.16639000000001 -20.176720000000003 -58.18347000000001 -19.86842 -59.11504 -19.35688 -60.043569999999995 -19.34273 -61.78634 -19.63372 -62.26596000000001 -20.51375 -62.29117 -21.05164 -62.685050000000004 -22.24903 -62.84648000000001 -22.034990000000004 ` Inside of `L.GML.AbstractMultiPolyline.parse` there is a call to `L.GML.MultiGeometry.prototype.parse.call` This call is returning a an array of LatLng objects. After this happens, a new layer of type L.Polyline is created and `setLatLngs` is being called with our array of LatLng objects. Inside of this method there is a call to `_convertLatLngs` with our array. Since this array already contains a list of LatLng objects the method returns NOTHING and then `redraw` is called on the layer. Sadly, there isn't a list of LatLng objects for the layer and redraw doesn't do anything.
ismail44 commented 8 years ago

Ok, so looking at AbstractMultiPolyline.js, how come, inside of the parse function, layer is set to new L.Polyline([]) and not new L.MultiPolyline([])?

kuzkok commented 8 years ago

Hi, are you use right branch? Master branch is for leaflet 1.x. For leaflet 0.7.x you should use code from leaflet-0.7.3 branch

ismail44 commented 8 years ago

It looks like 1.x is still beta and their website says 0.7.7 is the "good version"

On Mar 2, 2016, at 1:24 AM, kuzkok notifications@github.com wrote:

Hi, are you use right branch? Master branch is for leaflet 1.x. For leaflet 0.7.x you should use code from leaflet-0.7.3 branch

— Reply to this email directly or view it on GitHub.

kuzkok commented 8 years ago

Ok, so looking at AbstractMultiPolyline.js, how come, inside of the parse function, layer is set to new L.Polyline([]) and not new L.MultiPolyline([])

this changes were made for leaflet beta1 compatibility, if you see to leaflet-0.7.3 branch there will be L.MultiPolyline([])

ismail44 commented 8 years ago

Ok... so, I guess the answer is to swtich to 1.0. I'm a bit uncomfortable switching to "beta", but it seems to be the only way.

Thanks.

On Wed, Mar 2, 2016 at 8:31 AM, kuzkok notifications@github.com wrote:

Ok, so looking at AbstractMultiPolyline.js, how come, inside of the parse function, layer is set to new L.Polyline([]) and not new L.MultiPolyline([])

this changes were made for leaflet beta1 compatibility, if you see to leaflet-0.7.3 branch https://github.com/Flexberry/Leaflet-WFST/blob/leaflet-0.7.3/src/Format/Parsers/Layers/AbstractMultiPolyline.js there will be L.MultiPolyline([])

— Reply to this email directly or view it on GitHub https://github.com/Flexberry/Leaflet-WFST/issues/29#issuecomment-191239097 .

kuzkok commented 8 years ago

You can use leaflet 0.7.7 and this plugin code from leaflet-0.7.3 branch, it support all leaflet 0.7.x versions. Its just a branch name, not fixed leaflet version.

ismail44 commented 8 years ago

Ahhh... I see. Thanks so much!

On Wed, Mar 2, 2016 at 9:03 AM, kuzkok notifications@github.com wrote:

You can use leaflet 0.7.7 and this plugin code from leaflet-0.7.3 branch, it support all leaflet 0.7.x versions. Its just a branch name not fixed leaflet version.

— Reply to this email directly or view it on GitHub https://github.com/Flexberry/Leaflet-WFST/issues/29#issuecomment-191248978 .

ismail44 commented 8 years ago

I thought you were talking about the Leaflet project's version... no this project's version.

Thanks again for all your help. Selecting the correct version of WFST works just as expected.