Posted by agentrickard on November 5, 2009 at 8:35pm
Jump to:
| Project: | Mapstraction |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (works as designed) |
Issue Summary
This is a follow-up to #437644: Set initial point dynamically.
I want the map to auto-center, but I would still like to set the Zoom level. This requires a JS change that I don't quite comprehend, and removing the #processing dependency on the zoom form item.
Comments
#1
auto centering and zoom is actually one step in the Mapstraction library. If you think about it, the zoom is simply set to allow all the points to fit in the map when you autocenter.
#2
To resolve the problem of auto zooming in too far when there is just one point to display on the map you can add this bit of code to the mapstraction core js file mxn.core.js in the function that handles the auto centering and zoom at the end of the autoCenterAndZoom function before the bounding box is set. You can adjust the '.002' to whatever you desire for a minimum zoom level to start with.
add this
if(lat_min == lat_max){
lat_max = (lat_max+.002);
lon_max = (lon_max+.002);
lat_min = (lat_min-.002);
lon_min = (lon_min-.002);
}
before this
this.setBounds( new BoundingBox(lat_min, lon_min, lat_max, lon_max) );
around line 750 in mxn.core.js