On Thu, Apr 10, 2008 at 12:39 PM, groby <[EMAIL PROTECTED]> wrote: > > Hello, > > I am fairly new to OpenLayers and GIS in general and new to this list. I > have just setup an OpenLayers page. I am using MapServer as my WMS Server > and my data is held in PostGIS tables. > > I would like to know how can I create a way for a user to input text and to > zoom to the feature specified by the text. > > An example of what I am trying to accomplish: > Take the Feature Info Example at > http://www.openlayers.org/dev/examples/getfeatureinfo.html. If I wanted to > make it so a user could type in a country name then have the map zoom to the > extent of the country, how would I do so? It needs to be a general enough > example I could use it with any text field (for example, a Serial Number). > > I have found a few previous postings that seem to be asking a similar > question but not many answers. Any pointers to a nice or ugly solution are > appreciated. > > Thanks. > > Greg
There are a couple ways to get an extent. 1. Making a non-WMS call to mapserver like: http://localhost/cgi-bin/mapserv?map=/path/to/mapfile.map&mode=itemnquery &qitem=id&qstring=123456&qlayer=ownership&mapext=shapes Using a simple mapfile like: [minx], [miny] [maxx], [maxy] Would return the extent of the feature(s) where id=123456. You could then use those values to set the OL extent. You can also use itemquery and itemnquery modes to highlight feature(s). 2. If your data in in PostGIS you can call the extent() function e.g.: SELECT extent(the_geom) FROM sometable WHERE id=123456; I have a small php page that I call with the query parameters and it returns the extent, which I then use to set the extent in the browser. In the mapfile I have a layer styled with a bright highlight. The layer has a filter so I again pass the id=123456 to select the objects that I want to highlight e.g.: FILTER "%id%" These suggestions may not be the WMS way, or the OL way, but they are tried-and-true MapServer methods for highlighting features and getting extents. HTH -- Richard Greenwood [EMAIL PROTECTED] www.greenwoodmap.com _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
