Hey PX,
I suffered some of the same issues as you earlier today but managed to get
it all solved. You say you've done all that the other posters suggested
(version=1.0.0, separate gml parse/read, and redraw your highlights layer)
but have another look.
Separating the GML parse/read solved it for me ...
Peace out, SFS
======
var map = null;
var highlight, highstyle;
function PageInit() {
//alert("PageInit");
MapInit();
}
function MapInit() {
if (document.getElementById("MapDiv")) {
//alert("page with map");
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:900913"),
units: "m",
numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new
OpenLayers.Bounds(-20037508,-20037508,20037508,20037508.34)
};
map = new OpenLayers.Map("MapDiv", options);
var osmt = new OpenLayers.Layer.OSM();
var gsat = new OpenLayers.Layer.Google(
"Satellite",
{ type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels:
20 }
);
var wms = new OpenLayers.Layer.WMS(
"HFN Land Data",
"http://geoserver.cloverpoint.com:8080/geoserver/wms/",
{ 'srs': 'EPSG:900913', 'layers': 'HFN-Base', 'format':
'image/png',
'transparent': true },
{ 'isBaseLayer': false }
);
highstyle = { fillColor:'#cccccc', strokeColor:'#ff0000', stroke: 4,
fillOpacity: 0.75};
highlight = new OpenLayers.Layer.Vector("Selected Feature(s)",
{isBaseLayer:false, features:[], visibility:true}
);
map.addLayers([gsat, osmt, highlight, wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.Permalink());
SetMapCenter(-13912365.86819, 6261517.68686);
} else {
//alert("no map");
}
}
var wfsbase =
'http://geoserver.cloverpoint.com:8080/geoserver/wfs?version=1.0.0';
var vid;
var tid;
function PrepFeatureHighlights(source) {
vid = source.options[source.selectedIndex].value;
tid = source.options[source.selectedIndex].text;
//alert(id);
var wfsurl = wfsbase +
'&REQUEST=getFeature&typename=HFNSHP:Cadastre_poly&srsName=EPSG:900913&filter=<ogc:Filter
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml"
xmlns:gmgml="http://www.intergraph.com/geomedia/gml"><ogc:PropertyIsEqualTo><ogc:PropertyName>CADID</ogc:PropertyName><ogc:Literal>'+vid+'</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>';
//alert(wfsurl);
OpenLayers.loadURL(wfsurl,'', null, ZoomAndHighlight);
}
function ZoomAndHighlight(response) {
var gmlparser = new OpenLayers.Format.GML();
var gmlfeatures = gmlparser.read(response.responseText);
//alert("Features (" + gmlfeatures.length + ")... \n\n" +
response.responseText);
highlight.destroyFeatures();
highlight.addFeatures(gmlfeatures);
highlight.setVisibility(true);
highlight.redraw();
var zExtent = highlight.getDataExtent();
map.zoomToExtent(zExtent);
map.zoomOut();
var popup = new OpenLayers.Popup("Property Info",
map.getCenter(),
new OpenLayers.Size(200,200),
"<u>Property Information (" + vid + ")</u><p>Parse full property
definition from GIS response into this panel ...</p>",
true
);
map.addPopup(popup);
}
function SetMapCenter(y,x) {
var mapCenter = new OpenLayers.LonLat(y,x);
//mapCenter.transform(new OpenLayers.Projection("EPSG:900913"),
map.getProjectionObject());
map.setCenter(mapCenter, 10);
}
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Question-on-highlighting-a-feature-using-WFS-tp5543113p5573398.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users