[OpenLayers-Users] Search possible with OpenLayers?

Mapmaker bmcbride at cha-llp.com
Fri Mar 13 23:31:05 EDT 2009


Asle,

I have been able to accomplish basic search functionality using XML and
JavaScript based on the code here: http://snippets.dzone.com/posts/show/2719

Basically, I calculate the bounding box values (X_MAX, Y_MAX, XMIN, YMIN)
for every polygon feature in my layer and add that as an attribute in my
database.  Once I have the bounding coordinates, I can concatenate the
fields I want and build a javascript html link to zoom to the extents of the
feature- something like this:

<a href="javascript: map.zoomToExtent(new
OpenLayers.Bounds(-74.101606552,44.400644696,-73.273634891,45.039590722);"
target="_top">Zoom To</a>

Convert your attribute table with the link field to an XML file and use the
code from the above link to build your search box.  The search will return a
list of results with links to "Zoom To" the feature.

This works great with GeoServer because you can place everything in the
"www" folder and not have to worry about proxies or cross domain issues.

Best of luck!

BRYAN


Asle Benoni wrote:
> 
> Hello,
> I am getting things to work with Openlayers now. So I can show layers,
> turn
> them on and off, navigate etc.
> But now I am putting together a map where some of the layers contain
> certain
> information I want to do a search on. In my PostgreSQL database the table
> includes gis data but also other fields. I.ex. I display some locations
> and
> I want to be able to
> 
> - search for locations
> - when mouse hovers over a location the user gets a popup with a link so
> he
> can download a PDF with information about the location
> 
> Is this possible with OpenLayers or do I have to go on to another
> framework
> like MapFish, MapBender, ExtJS etc. In that case does anyone have
> something
> to suggest?
> 
> Thanks for any advice!
> 
> /asle
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Search-possible-with-OpenLayers--tp2474939p2476971.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list