[OpenLayers-Users] Locate objetcts in the maps

Kris Geusebroek kgeusebroek at xebia.com
Fri May 1 02:01:22 EDT 2009


Hi,

 

You oculd create a wfs getFeature request with a Filter matching a unique value of your object to locate.

You’ll get back a result with you can parse to find the geometry of the object and call setCentre on the map or so or zoomToExtent.

 

Other way to do is is you have already a Vector Layer with wfs protocol added to it something like this:

 

function findObject(propertyName, uniqueValue) {

 

                               var uniqueFilter = new OpenLayers.Filter.Comparison(

                                               {

                                                               type: OpenLayers.Filter.Comparison.EQUAL_TO,

                                                               property: propertyName,

                                                               value: uniqueValue

                                               }

                               );

 

                               var response = wfsLayer.protocol.read({

                                               maxFeatures: 1,

                                               filter: uniqueFilter,

                                               callback: function(result) {zoomToTheExtentOfTheResultingFeature(result);}

                               });

}

 

function zoomToTheExtentOfTheResultingFeature(result) {

                if (result.features.length > 0) {

                               var feature = result.features[0];

                               //var center = feature.geometry.getBounds().getCenterLonLat();

                               //map.setCenter(center);

                               var ext = feature.geometry.getBounds();

                               map.zoomToExtent(ext);

                }

}

 

Hope this helps

 

Cheers Kris

 

From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On Behalf Of fsalas
Sent: Thursday, April 30, 2009 5:53 PM
To: users at openlayers.org
Subject: [OpenLayers-Users] Locate objetcts in the maps
Importance: High

 

Hi all,

 

I have a little problem..

 

I need locate one objetcs Ej. lake,house , etc. by your fields value. And make a Zoom to extend this objects 

How impements this code , I have geoserver.

 

Does anyone have a function for this task?

 

Regards 

 

Francisco Salas

 


___________________________________
Dirección de Comunicaciones
Grupo Empresarial GEOCUBA
Este mensaje esta libre de virus. 
Revisado por Kaspersky Antivirus
----------------------------------------------------------------------
Definition count: 331867 Definition date: 6/18/2007 SecurityPlus version: 3.0.5 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090501/27b2c8b9/attachment.html


More information about the Users mailing list