Thanks for the info. Got the featureselected event working.<br><br>I am having the issue of obtaining attributes of a feature.<br><br>This is how my code look like.<br><br> wfs_cities = new OpenLayers.Layer.WFS( "WFS Cities",<br>
"<a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>",<br> {typename: "topp:cities",<br> extractAttributes : true<br>
},<br> {styleMap: new OpenLayers.StyleMap({<br> "default": cities_symbolizer//,<br> //"select" : cities_symbolizer_select<br>
})}<br> );<br><br> var selectControl = new OpenLayers.Control.SelectFeature(<br> wfs_cities,<br> {onSelect : onFeatureSelect});<br> <br>
function onFeatureSelect(feature) { <br> alert(feature.attribute.citiy_name);<br> } <br> <br> map.addControl(selectControl);<br> selectControl.activate();<br>
<br>The alert above does not show any output.<br>By following this method is it necessary to do the following also to extract attribute information using GetFeature ?<br><br> wfs_cities.events.register('featureselected', map, function (e) {<br>
document.getElementById('nodelist').innerHTML = "Loading";<br> var url = wfs_cities.getFullRequestString(<br> {<br> //SERVICE : 'WFS',<br>
REQUEST: "GetFeature",<br> EXCEPTIONS: "application/vnd.ogc.se_xml",<br> //BBOX: map.getExtent().toBBOX(),<br> //X: e.xy.x,<br>
//Y: e.xy.y,<br> INFO_FORMAT: 'text/html',<br> //QUERY_LAYERS: map.layers[2].params.LAYERS,<br> PROPERTYNAME: 'the_geom',<br>
FEATURE_COUNT: 50<br> //FILTER: '<wfs:FeatureCollection xmlns:wfs="<a href="http://www.opengis.net/wfs">http://www.opengis.net/wfs</a>" xmlns:ogc="<a href="http://www.opengis.net/ogc">http://www.opengis.net/ogc</a>" service="WFS" version="1.1.0" xmlns:gml="<a href="http://www.opengis.net/gml">http://www.opengis.net/gml</a>"><gml:featureMember><ogc:Filter><ogc:Contains><ogc:PropertyName>the_geom</ogc:PropertyName><gml:Point><gml:coordinates>'+lonlatxy+'</gml:coordinates></gml:Point></ogc:Contains></ogc:Filter></gml:featureMember></wfs:FeatureCollection>',<br>
//WIDTH: map.size.w,<br> //HEIGHT: map.size.h<br> },<br> "<a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>"<br>
);<br><br>Thanks in advance<br><br><br><div class="gmail_quote">2008/10/28 Eric Lemoine <span dir="ltr"><<a href="mailto:eric.c2c@gmail.com">eric.c2c@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
As Arnd said you should use vectors styled with externalgraphic and<br>
the select feature control to be able to select your markers and<br>
display a popup on feature selection. To be notified on feature<br>
selection register a listener on the layer's featureselected event.<br>
featureselected listeners receive an object with a feature property<br>
referencing the selected feature. This is shown in the example Arnd<br>
pointed you to. Eric<br>
<br>
2008/10/28, Indika Tantrigoda <<a href="mailto:indika85@gmail.com">indika85@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> Thanks for the reply.<br>
><br>
> It seems that when I click within the marker, I get different lon, lat<br>
> values.<br>
><br>
> Is it necessary to bind the markers to something ?<br>
><br>
> Also with the extractAttributes:true, how can I access the attributes of the<br>
> feature ?<br>
><br>
> Regards,<br>
> Indika<br>
><br>
> 2008/10/27 Arnd Wippermann <<a href="mailto:arnd.wippermann@web.de">arnd.wippermann@web.de</a>><br>
><br>
>> you can use a select control for the wfs layer.<br>
>><br>
>> <a href="http://openlayers.org/dev/examples/select-feature-openpopup.html" target="_blank">http://openlayers.org/dev/examples/select-feature-openpopup.html</a><br>
>><br>
>> If you have load the wfs layer with extractAttributes: true, then your wfs<br>
>> data are saved in the attributes of the features.<br>
>><br>
>> Arnd Wippermann<br>
>><br>
>> ------------------------------<br>
>> *Von:* <a href="mailto:users-bounces@openlayers.org">users-bounces@openlayers.org</a> [mailto:<a href="mailto:users-bounces@openlayers.org">users-bounces@openlayers.org</a>]<br>
>> *Im Auftrag von *Indika Tantrigoda<br>
>> *Gesendet:* Montag, 27. Oktober 2008 16:17<br>
>> *An:* OpenLayers users mailing list<br>
>> *Betreff:* [OpenLayers-Users] WFS Layers, Markers, Popups<br>
>><br>
>> Hi,<br>
>> I have a wfs layer that displays points on my map, using markers.<br>
>> I would like to have a popup that displays data regarding the point which<br>
>> would get activated for a click event.<br>
>><br>
>> I tried the following but, it seems to return all the data regarding the<br>
>> wfs layer, not the single point, irrespective of<br>
>> where I click on the map.<br>
>><br>
>> wfs_cities.events.register('click', map, function (e) {<br>
>> document.getElementById('nodelist').innerHTML =<br>
>> "Loading...<br>
>> please wait...";<br>
>> var url = map.layers[2].getFullRequestString(<br>
>> {<br>
>> REQUEST: "GetFeature",<br>
>> EXCEPTIONS: "application/vnd.ogc.se_xml",<br>
>> BBOX: map.getExtent().toBBOX(),<br>
>> X: e.xy.x,<br>
>> Y: e.xy.y,<br>
>> INFO_FORMAT: 'text/html',<br>
>> QUERY_LAYERS: map.layers[2].params.LAYERS,<br>
>> FEATURE_COUNT: 50,<br>
>> WIDTH: map.size.w,<br>
>> HEIGHT: map.size.h<br>
>> },<br>
>> "<a href="http://localhost:8080/geoserver/wfs" target="_blank">http://localhost:8080/geoserver/wfs</a>"<br>
>> );<br>
>><br>
>> Any ideas how I can get around this ?<br>
>><br>
>> Thanks in advance.<br>
>><br>
>> Regards,<br>
>> Indika<br>
>><br>
><br>
</div></div></blockquote></div><br>