Hello Jian, I was able to finally get the application running. I ran across a posting that had the "featureNS" statement I've inserted below: var polygonLayer = new OpenLayers.Layer.WFS( "HOMELOT", "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apache/htdocs/homeinfo_w fs_attr.map&", {typename: 'taxlots', featureNS: "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apache/htdocs/homeinfo_w fs_attr.map", typename: 'ms:taxlots'}, {extractAttributes:true, visibility: false}); //, style: OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default'])}); I think the trick was having the typename: 'ms:taxlots' parameter (taxlots is the name of my layer). Once I did that I can see the WFS layer display, I can click on the tax lot polygon and the framedcloud popup does pop up and the attributes are displayed. And the tax lot polygon is highlighted. The next problem now is that the WFS layer displays REAL slow. Anything over 20 - 30 records takes too long. I've been doing more reading on that and I'm wondering if WFS is just that way. So in the meantime I've switched back to using a WMS layer and the getfeatureinfo method of displaying a popup.
Cress ________________________________ From: Jian Zhou (via Nabble) [mailto:[email protected]] Sent: Friday, October 09, 2009 2:41 AM To: BATES Cress A (Lane Cty) Subject: Re: [OpenLayers-Users] WFS Popup Attributes undefined I have the same questiong like you. So your OpenLayers application is running and all layers are displayed fine? What's the output after clicking on an object?Can you see the popup fine? Regards Cress B. wrote: I'm fairly new to OpenLayers and have been trying to get the attributes from my WFS mapfile to display in a popup window. I would like the user to be able to click on a polygon and have the attributes display as a list in a popup. I've started with the select-feature-openpoup.html example and have inserted by own WFS mapfile. I can load my polygon shapefile as a WFS service and see them load as orange polygons - although they load REAL slow. When I activate the popup option and click on a polygon the popup window comes up and the polygon is highlighted in blue. The popup is returning the area of the polygon as part of the 'feature.geometry.getArea()' parameter; but the other attributes in my shapefile are "undefined" in the popup. I've hacked away for several days, reading almost all the posts dealing with popup, WFS, attributes... and still can't figure out what I'm doing wrong. So I'm not sure if my WFS mapfile is wonky or if my script in OpenLayers is missing something. Below is my Mapfile: MAP NAME 'TAXLOT' STATUS ON IMAGETYPE PNG24 TRANSPARENT ON EXTENT 4239905 896089 4247235 902911 SIZE 1000 800 IMAGECOLOR 152 252 210 UNITS Feet SHAPEPATH "/ms4w/apps/tutorial/data" FONTSET "/ms4w/apps/tutorial/fonts/fonts.list" SYMBOLSET "/ms4w/apps/tutorial/symbols/symbols35.sym" WEB IMAGEPATH "/ms4w/tmp/ms_tmp/" IMAGEURL "/ms_tmp/" METADATA "wfs_title" "TAXLOT" "wfs_onlineresource" "http://localhost/cgi_bin/mapserv.exe?&" #map=homeinfo_wfs.map&" "wms_srs" "EPSG:32127" END #end metadata END #end web PROJECTION "init=epsg:32127" END #end projection LAYER # Taxlots polygon layer begins here NAME "taxlots" CONNECTIONTYPE WFS METADATA "wfs_typename" "taxlots" "wfs_request_method" "GET" "gml_featureid" "FID" "gml_include_items" "all" "queryable" "true" END DATA 'HomeTaxlots' TYPE POLYGON STATUS ON PROJECTION "init=epsg:32127" END DUMP TRUE TEMPLATE /ms4w/apps/template/foo.html CLASS NAME "lots" STYLE COLOR 155 155 255 OUTLINECOLOR 0 15 27 END TEMPLATE "ttt_query.html" END END # Taxlots polygon layer ends here END # All map files must come to an end just as all other things must come to... And this is the OpenLayers script piece for the popup: <script type="text/javascript"> var map, drawControls, selectControl, selectedFeature; var lon = 4243545; var lat = 900150; var zoom = 0; var map, test_wfs, layer; function onPopupClose(evt) { selectControl.unselect(selectedFeature); } function onFeatureSelect(feature) { selectedFeature = feature; var maplot = selectedFeature.attributes['MAPLOT']; var lot = selectedFeature.attributes['LOT']; var acres = selectedFeature.attributes['ACRES']; var taxcode = selectedFeature.attributes['TAXCODE']; popup = new OpenLayers.Popup.FramedCloud("info", feature.geometry.getBounds().getCenterLonLat(), null, "<div style='font-size:.8em'>TaxLot: " + maplot +"<br />Lot: " + lot+"<br />Acres: " +acres +"<br/>Taxcode: " +taxcode+"<br/>Area: " + feature.geometry.getArea()+"</div>", null, true,onPopupClose); feature.popup = popup; map.addPopup(popup); } function onFeatureUnselect(feature) { map.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null; } function init(){ var options = { projection: new OpenLayers.Projection("EPSG:32127"), displayProjection: new OpenLayers.Projection("epsg:32127"), units: "feet", maxResolution: "auto", allOverlays: true, maxExtent: new OpenLayers.Bounds(4239905, 895089, 4247235, 906500) }; map = new OpenLayers.Map("map",options ); var polygonLayer = new OpenLayers.Layer.WFS( "TAXLOT", "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apache/htdocs/homeinfo_w fs_good.map&", {typename: 'taxlots'}); //var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer"); map.addLayers([polygonLayer]); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.MousePosition()); selectControl = new OpenLayers.Control.SelectFeature(polygonLayer, {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect}); drawControls = { polygon: new OpenLayers.Control.DrawFeature(polygonLayer, OpenLayers.Handler.Polygon), select: selectControl }; for(var key in drawControls) { map.addControl(drawControls[key]); } map.setCenter(new OpenLayers.LonLat(0, 0), 3); } function toggleControl(element) { for(key in drawControls) { var control = drawControls[key]; if(element.value == key && element.checked) { control.activate(); } else { control.deactivate(); } } } <http://n2.nabble.com/images/smiley/anim_handshake.gif> <http://n2.nabble.com/images/smiley/anim_handshake.gif> <http://n2.nabble.com/images/smiley/anim_handshake.gif> ________________________________ View message @ http://n2.nabble.com/WFS-Popup-Attributes-undefined-tp3778098p3793430.ht ml To unsubscribe from WFS Popup Attributes undefined, click here < (link removed) AY28ubGFuZS5vci51c3wzNzc4MDk4fC03MDgxNzUwNjg=> . -- View this message in context: http://n2.nabble.com/WFS-Popup-Attributes-undefined-tp3778098p3795376.html Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
