<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=843432317-28102008>Try this, to get all attributes for the
feature:</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=843432317-28102008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2>function
onFeatureSelect(feature)
{
<BR> var Msg="";<BR> for(var key in
feature.attributes)<BR> Msg
+= <SPAN class=843432317-28102008>key + ":" +
</SPAN>feature.attributes[key] + "\r\n";<BR>
alert(Msg);<BR>}</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=843432317-28102008>but perhaps you mean </SPAN></FONT><FONT face=Arial
color=#0000ff size=2>city_name<SPAN class=843432317-28102008> instead of
</SPAN>citiy_name<SPAN class=843432317-28102008>.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=843432317-28102008></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=843432317-28102008>Arnd
Wippermann</SPAN></DIV>
<DIV dir=ltr align=left><BR></DIV></FONT><BR>
<DIV class=OutlookMessageHeader lang=de dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>Von:</B> indika85@gmail.com
[mailto:indika85@gmail.com] <BR><B>Gesendet:</B> Dienstag, 28. Oktober 2008
11:47<BR><B>An:</B> Eric Lemoine<BR><B>Cc:</B> Arnd Wippermann;
users@openlayers.org<BR><B>Betreff:</B> Re: [OpenLayers-Users] WFS Layers,
Markers, Popups<BR></FONT><BR></DIV>
<DIV></DIV>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="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">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></BODY></HTML>