jorix / OL-FeaturePopups

FeaturePopups wraps the management of popups and SelectFeature on OpenLayers.
http://jorix.github.com/OL-FeaturePopups/examples/feature-popups.html
MIT License
53 stars 17 forks source link

Click a link, shows a single popup: doesn't work at wfm cluster layer #29

Closed Bear4 closed 8 years ago

Bear4 commented 8 years ago

I try this great tool OL-FeaturePopups (thanks!) and everything works fine besides click a link.

I have WFS layer (geoserver + postgis). The layer: [wc_tab_reg] has attributes: fid:.[v_wzl_tab_regulacyjne.fid--3fa1d85615239af50e5-268e] - it's GeoServer id gis_id: [30321] adres_wezla: [Mieszka I 11] tab_regulacyjne: [Mieszka I 11: 80/55]

My popup code:

 var fpControl = new OpenLayers.Control.FeaturePopups({
 boxSelectionOptions: {},
 layers: [ [...],
      wc_tab_reg, {templates: {
      // hover: single & list
         hover: '${.adres_wezla}',
         hoverList: '<b>${count}</b><br>${html}',
         hoverItem: '${.adres_wezla}<br>',
      // select: single & list
         single: '<div><h2>${.adres_wezla}</h2>${.tab_regulacyjne}</div>',
         item: '<li><a href="#" ${showPopup()}>${.adres_wezla}</a></li>'
                }}]
    ] });

And popup is displayed after selected features cluster, I have list of links, but when click on link nothing happens...

popup_cluster

I wonder whether it is caused by a WFS layer? In example there is KML source of features.

And structure wfs feature from browser devTools:

gml

My version OL2 - 2.13.1

jorix commented 8 years ago

It is likely to be due to complex fid (with dots and dashes) of the features.

I will have to do tests to confirm this, and if as I think, I'll make a patch (maybe on weekend I could work on this)

@Bear4: I would be helpful give me the url (if you have published) or send me a response XML from the server.

Bear4 commented 8 years ago

Thanks for replay! I'm sorry I have a local server without the ability to access the public network. The GML file fragment (from Linux, Tomcat, Geoserver) looks like this:

<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ant_mapy="http://mpec.bialystok.pl/mapy.telemetria/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberMatched="unknown" numberReturned="0" timeStamp="2016-01-15T11:08:43.025Z" xsi:schemaLocation="http://www.opengis.net/gml/3.2 http://mpecfs7:8080/geoserver/schemas/gml/3.2.1/gml.xsd http://www.opengis.net/wfs/2.0 http://mpecfs7:8080/geoserver/schemas/wfs/2.0/wfs.xsd http://mpec.bialystok.pl/mapy.telemetria/ http://mpecfs7:8080/geoserver/ant_mapy/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=ant_mapy%3Av_wzl_tab_regulacyjne">
<wfs:member>
<ant_mapy:v_wzl_tab_regulacyjne gml:id="v_wzl_tab_regulacyjne.fid-53e49795_15244f6c3e6_13cd">
<ant_mapy:geom>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#3857" srsDimension="2">
<gml:pos>2578057.902966 7005516.352426</gml:pos>
</gml:Point>
</ant_mapy:geom>
<ant_mapy:id_gis>13531</ant_mapy:id_gis>
<ant_mapy:adres_wezla>11 Listopada</ant_mapy:adres_wezla>
<ant_mapy:tab_regulacyjne>11 Listopada: 75/50</ant_mapy:tab_regulacyjne>
</ant_mapy:v_wzl_tab_regulacyjne>
</wfs:member>
...
</wfs:FeatureCollection>

And the same GML but from Windows 2008, Geoserver. It looks like that fid is a little different:

<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ant_mapy="http://mpec.bialystok.pl/mapy.telemetria/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberMatched="unknown" numberReturned="0" timeStamp="2016-01-15T11:37:10.856Z" xsi:schemaLocation="http://www.opengis.net/gml/3.2 http://mpecfs5:8080/geoserver/schemas/gml/3.2.1/gml.xsd http://www.opengis.net/wfs/2.0 http://mpecfs5:8080/geoserver/schemas/wfs/2.0/wfs.xsd http://mpec.bialystok.pl/mapy.telemetria/ http://mpecfs5:8080/geoserver/ant_mapy/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=ant_mapy%3Av_wzl_tab_regulacyjne">
<wfs:boundedBy>
<gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
<gml:lowerCorner>2572980.56031991 7005416.35242589</gml:lowerCorner>
<gml:upperCorner>2586366.30653831 7010979.82667281</gml:upperCorner>
</gml:Envelope>
</wfs:boundedBy>
<wfs:member>
<ant_mapy:v_wzl_tab_regulacyjne gml:id="v_wzl_tab_regulacyjne.fid--3fa1d856_152450e7912_3f22">
<gml:boundedBy>
<gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#3857" srsDimension="2">
<gml:lowerCorner>2578087.902966 7005416.352426</gml:lowerCorner>
<gml:upperCorner>2578087.902966 7005416.352426</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<ant_mapy:geom>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#3857" srsDimension="2">
<gml:pos>2578057.902966 7005516.352426</gml:pos>
 </gml:Point>
 </ant_mapy:geom>
 <ant_mapy:id_gis>13531</ant_mapy:id_gis>
 <ant_mapy:adres_wezla>11 Listopada</ant_mapy:adres_wezla>
<ant_mapy:tab_regulacyjne>11 Listopada: 75/50</ant_mapy:tab_regulacyjne>
</ant_mapy:v_wzl_tab_regulacyjne>
</wfs:member>
...
</wfs:FeatureCollection>

The difference between fid (double dash after fid versus single dash): Linux Tomcat Geoserver v 2.8.1:

<ant_mapy:v_wzl_tab_regulacyjne gml:id="v_wzl_tab_regulacyjne.fid-53e49795_15244f6c3e6_13cd">

Windows Geoserver v 2.8.1:

<ant_mapy:v_wzl_tab_regulacyjne gml:id="v_wzl_tab_regulacyjne.fid--3fa1d856_152450e7912_3f22">

Unfortunately fid is automatic adding by GeoServer (I don't know whether it is possible to change this, probably not.)

If You need some more or other information please tell.

jorix commented 8 years ago

@Bear4 Please try this patch: 21ec4661017fb14162cd553974fcc5d6f894bb47

Can you confirm if it works with you maps?

Bear4 commented 8 years ago

Seems to be fine (on Windows version GeoServer 2.8.1). I'll check on Linux-Tomcat-GeoServer and answer.

Many thanks, good job. I appreciate it.

Bear4 commented 8 years ago

Also on Linux-Tomcat-GeoServer works beautiful. One more time thanks.