2

Expected user behavior is that when user selects the County from a drop-down, the map should zoom to its max extents. I am using SQL View (Postgis on 9.3) and since I do not know the bounds, I gave the Max Bounds of the FL State. Not able to create layer without giving bounds. Can the boundaries be inferred from the SQL? The SQL for the view is as shown below:

   select ST_XMin(b.geom) as xmin,ST_YMin(b.geom) as ymin, ST_XMax(b.geom) as xmax,
   ST_YMax(b.geom) as ymax, a.zcta5ce10, a.geom
   from us_zip a, tl_2013_us_county b
   where b.statefp='12'
   and lower(b.name)='%COUNTY_NAME%'
   and ST_contains(b.geom,a.geom) order by zcta5ce10

If it is not possible, I'm thinking of getting the max bounds for the selected county before invoking the OpenLayers map.

1

If I understand you correctly, your view already returns the bounds for a county. What you need to do is change the map itself, correct?

You should take a look at the map object's zoomToExtent() method. Since you have the min/max for both X and Y, you can pass that in as an array.

  • am a newbie, yes it is available as a Map property. Do not know how to read this from OpenLayers. Can these properties be passed by Geoserver. I see examples on SLD to define the labels, color etc for map. Can the same be used? – patb23 Jan 11 '14 at 12:16
  • You can't use SLD to change the boundaries of the map. It seems what you need to do is use the view you created to determine the boundaries of the county. You do this by using something like PHP PDO, not OpenLayers. – Brynne Jan 13 '14 at 22:30
  • Thanks for confirming. As I mentioned in the last line of my question, I got it working by supplying the bounds beforehand.Your confirmation (in the comment section) is the answer I was looking for. – patb23 Jan 14 '14 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.