[OpenLayers-Users] Is there an easy way to center and zoom the map automatically based on the placemarks that are on it?

Greg Allensworth gregor at greeninfo.org
Tue Jul 3 14:52:00 PDT 2012


On 7/3/2012 2:11 PM, Aaron E-J wrote:
> Is there an easy way to center and zoom the map automatically based on
> the placemarks that are on it?I have it so that one can filter
> placemarks based on user input but I'm not sure how to dynamically
> update the map to fit the newly filtered content.Thanks for any insight
> that can be given regarding this matter.

An OpenLayers.Layer.Markers instance, has a method called 
getDataExtent() This should do most of what you want.

It's not automatic, though. You'd still need to call map.zoomToExtent() 
after the markers have been added to the layer.

http://dev.openlayers.org/docs/files/OpenLayers/Layer/Markers-js.html

-- 
Greg Allensworth, Web GIS Developer
BS  A+  Network+  Security+  Linux+  Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510  San Francisco CA 94104
PH: 415-979-0343 x302  FX: 415-979-0371    email: gregor at greeninfo.org
Web: www.GreenInfo.org     www.MapsPortal.org

Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org




More information about the Users mailing list