getting extents for displaying individual states

Eric Bridger eric at GOMOOS.ORG
Mon Aug 30 16:36:53 EDT 2004


On Mon, 2004-08-30 at 13:20, Bob Cook wrote:
> I'm working with a map of the entire United States (including Alaska,
> Hawaii, and other US territories).
>
> I would like to allow users to select an individual state (or territory)
> from a dropdown list and have the map center around that state, and zoom
> in to it.
>
> Is there any easy way of programmatically setting my map's extents
> (without simply hard-coding extents for each state) so that it centers
> on one state?
>
> I'm using PHP/Mapscript.
>

Assuming all your states are in one layer you will need to execute an
attribute  query against the layer based on the name of the state
entered.($layer->queryByAttrbute()) The query results will give you
access to the shape of the state you want. That shape has a bounds
member which is a rectangle which can be use to set the extent of you
new map.
$minx = $shape->{bounds}->{minx};
etc.



More information about the mapserver-users mailing list