[Users] Highlight layer using Mapserver/Geoext/OL
Matt Priour
mpriour at kestrelcomputer.com
Thu Apr 1 00:24:09 CEST 2010
You should use a WFS GetFeature request in response to the click event in
your grid.
The grid record needs to have some kind of data attached to it that you can
use to create your filter on your GetFeature request.
If you're using GeoServer, then you can use a normal OGC Filter (created via
OpenLayers.Filter.XXX constructor) or you can use the simpler CQL_FILTER
param in your request.
I'm doing something similar in an application. I create a WFS protocol via
the WFSfromWMS function, assign a filter property and then call the read
function on the WFS protocol. The callback on that method then uses the
feature( s ) to zoom to an area on the map and highlight the feature using a
vector layer. I replace the feature( s) in the vector layer each time the
callback is run.
Here is a code snippet illustrating what I am doing. In this example I'm
simply adding a marker & doing a popup, rather than adding a vector feature.
wmsLayer = a record from a LayerStore
idField = the key for the field that contains the value we are looking for
featureId = the value to search for
useVector = [Boolean]
//create wfs protocol
var wfsProtocol = OpenLayers.Protocol.WFS.fromWMSLayer(wmsLayer.data.layer);
//get feature
var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: idField || wmsLayer.data.idField,
value: featureId
});
var scope ={
map:wmsLayer.data.layer.map,
'wmsLayer':wmsLayer.data.layer,
'filter':filter,
wmsRecord:wmsLayer
}
//if not using vector then just zoom to WMS location & do popup
if(!useVector){
wfsProtocol.read({
'scope':scope,
'filter':filter,
callback:Mgm.focusWmsFeature
});
}
//if using vector then add vector feature, zoom & do popup
else{
var vectorLayer =
(vectorLayerId)?MG.Layers.get(vectorLayerId):MG.Layers.get(wmsLayer.data.id);
scope[layer]=(vectorLayer)?vectorLayer.data.layer:null;
scope[layerRecord] = vectorLayer;
wfsProtocol.read({
'scope':scope,
'filter':filter,
callback:Mgm.focusWfsFeature
});
}
Matt Priour
Kestrel Computer Consulting
---------------------------------
From: Paul james
Sent: Wednesday, March 31, 2010 4:03 PM
To: Steve.Toutant at inspq.qc.ca
Cc: users-bounces at geoext.org ; users at geoext.org
Subject: Re: [Users] Highlight layer using Mapserver/Geoext/OL
Hi...
On Wed, Mar 31, 2010 at 5:39 PM, <Steve.Toutant at inspq.qc.ca> wrote:
Did you create the WMS for the roads? What is the format of the roads data,
.shp, spatial database?
Yes, I created a WMS layer for the roads... The format is Spatial Database
(Mssql2008) ,,,
I think you'll have to use a vector layer.
Just an idea, If you have many roads you should query the data to retreive
the road you need and add this road to the vector layer.
Yes I have many roads.... Do you have any sample/ideia how can I do that?
Query and add to vector?
Thanks
Paul james <pauljame at gmail.com>@geoext.org
Envoyé par : users-bounces at geoext.org
31/03/2010 04:24 PM AMichael Prieß <michael.priess at gmx.de>
ccusers at geoext.org
ObjetRe: [Users] Highlight layer using Mapserver/Geoext/OL
Thanks Michael...
But I think it will not help me...
I need Highlight a WMS layer and with FeatureStore, I need create a vector
layer...
Or am I missing something?
Thanks
On Wed, Mar 31, 2010 at 4:31 PM, Michael Prieß <michael.priess at gmx.de>
wrote:
Hi Paul,
maybe this would be helpful :)
http://dev.geoext.org/trunk/geoext/examples/feature-grid.html
> Any ideas how do that ?
_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
More information about the Users
mailing list