[OpenLayers-Users] Zooming functionality in OpenLayers for Openstreet maps
modala
modala.raghuveer at gmail.com
Mon Aug 13 08:25:46 PDT 2012
Hi,
I have any issue regarding the zooming functionality working. I am
using Open streets map for this work. I am able to zoom to countries when i
select from a drop down menu, but when i select a state from U.S drop down,
the zooming functionality doesn't work for states. Can any one help in this
regard.
function ZoomState(state) {
//(-80, 10, 80, 40);
//state_bounds = new OpenLayers.Bounds(
-62.333333,16.916667,-61.666667,17.733333 );
var state_bounds= new OpenLayers.Bounds(0,0,0,0);
var bFlag = false;
switch (state) {
case "0":
break;
case "AL":
state_bounds = new OpenLayers.Bounds(-84.8935, 30.1896, -88.472,
35.0089); bFlag=true;
break;
case "AK":
state_bounds = new OpenLayers.Bounds(-130,51.333333 ,-172,71.833333 );
bFlag=true;
break;
case "AZ":
state_bounds = new OpenLayers.Bounds(-109.045, 31.3292, -114.815,
37.0046); bFlag=true;
break;
case "AR":
state_bounds = new OpenLayers.Bounds(-89.6444, 33.0045, -94.6182,
36.4997); bFlag=true;
break;
case "CA":
state_bounds = new OpenLayers.Bounds(-114.129, 32.5304, -124.411,
42.0098); bFlag=true;
break;
case "CO":
state_bounds = new OpenLayers.Bounds(-102.042, 36.9922, -109.061,
41.0056); bFlag=true;
break;
case "CT":
state_bounds = new OpenLayers.Bounds(-71.7882, 40.9825, -73.7297,
42.0497); bFlag=true;
break;
case "DE":
state_bounds = new OpenLayers.Bounds(-75.0424, 38.4493, -75.7881,
39.8406); bFlag=true;
break;
case "DC":
state_bounds = new OpenLayers.Bounds(-76.9097, 38.8015, -77.1205,
38.9951); bFlag=true;
break;
case "FL":
state_bounds = new OpenLayers.Bounds(-80.029, 24.5183, -87.6372,
31.0021); bFlag=true;
break;
case "GA":
state_bounds = new OpenLayers.Bounds(-80.842, 30.3571, -85.6055,
35.002); bFlag=true;
break;
case "HI":
state_bounds = new OpenLayers.Bounds(-154.799,18.9155, -160.236,
22.2344); bFlag=true;
break;
case "ID":
state_bounds = new OpenLayers.Bounds(-111.044,41.9898, -117.24,
49.0015); bFlag=true;
break;
case "IL":
state_bounds = new OpenLayers.Bounds(-87.0181,36.9711, -91.5126,
42.5095); bFlag=true;
break;
case "IN":
state_bounds = new OpenLayers.Bounds(-84.7877,37.773, -88.0897,
41.7623); bFlag=true;
break;
case "IA":
state_bounds = new OpenLayers.Bounds(-90.1393,40.3745, -96.6357,
43.5046); bFlag=true;
break;
case "KS":
state_bounds = new OpenLayers.Bounds(-94.5927,36.9922, -102.049,
40.0045); bFlag=true;
break;
case "KY":
state_bounds = new OpenLayers.Bounds(-81.9642,36.4967, -89.5737,
39.1472); bFlag=true;
break;
case "LA":
state_bounds = new OpenLayers.Bounds(-88.8141,28.9181, -94.0458,
33.0206); bFlag=true;
break;
case "ME":
state_bounds = new OpenLayers.Bounds(-66.954,43.0648, -71.082, 47.4619);
bFlag=true;
break;
case "MD":
state_bounds = new OpenLayers.Bounds(-75.0459,37.9114, -79.4872,
39.724); bFlag=true;
break;
case "MA":
state_bounds = new OpenLayers.Bounds(-69.9254,41.237, -73.5084,
42.8867); bFlag=true;
break;
case "MI":
state_bounds = new OpenLayers.Bounds(-82.1229,41.6958, -90.4187,
48.3042); bFlag=true;
break;
case "MN":
state_bounds = new OpenLayers.Bounds(-89.4878,43.5021, -97.239,
49.3856); bFlag=true;
break;
case "MS":
state_bounds = new OpenLayers.Bounds(-88.098,30.1744, -91.6543,
34.9983); bFlag=true;
break;
case "MO":
state_bounds = new OpenLayers.Bounds(-89.1006,35.9951, -95.7744,
40.614); bFlag=true;
break;
case "MT":
state_bounds = new OpenLayers.Bounds(-104.04,44.3577, -116.051,
49.0018); bFlag=true;
break;
case "NE":
state_bounds = new OpenLayers.Bounds(-95.308,39.9999, -104.053,
43.0028); bFlag=true;
break;
case "NV":
state_bounds = new OpenLayers.Bounds(-114.039,35.0021, -120.005,
42.0003); bFlag=true;
break;
case "NH":
state_bounds = new OpenLayers.Bounds(-70.7135,42.6978, -72.5564,
45.3087); bFlag=true;
break;
case "NJ":
state_bounds = new OpenLayers.Bounds(-73.8936,38.9256, -75.5676,
41.3576); bFlag=true;
break;
case "NM":
state_bounds = new OpenLayers.Bounds(-103.001,31.3319, -109.05,
36.9994); bFlag=true;
break;
case "NY":
state_bounds = new OpenLayers.Bounds(-71.8559,40.4991, -79.7633,
45.0174); bFlag=true;
break;
case "NC":
state_bounds = new OpenLayers.Bounds(-75.4595,33.8445, -84.321, 36.589);
bFlag=true;
break;
case "ND":
state_bounds = new OpenLayers.Bounds(-96.5552,45.9351, -104.05,
49.0013); bFlag=true;
break;
case "OH":
state_bounds = new OpenLayers.Bounds(-80.5139,38.4025, -84.8199,
42.3244); bFlag=true;
break;
case "OK":
state_bounds = new OpenLayers.Bounds(-94.4307,33.6153, -103.001,
37.0009); bFlag=true;
break;
case "OR":
state_bounds = new OpenLayers.Bounds(-116.462,41.9925, -124.566,
46.2858); bFlag=true;
break;
case "PA":
state_bounds = new OpenLayers.Bounds(-74.69,39.7194, -80.5196, 42.5105);
bFlag=true;
break;
case "RI":
state_bounds = new OpenLayers.Bounds(-71.1206,41.1443, -71.8884,
42.0191); bFlag=true;
break;
case "SC":
state_bounds = new OpenLayers.Bounds(-78.5537,32.0492, -83.3544,
35.2161); bFlag=true;
break;
case "SD":
state_bounds = new OpenLayers.Bounds(-96.4366,42.4811, -104.057,
45.9444); bFlag=true;
break;
case "TN":
state_bounds = new OpenLayers.Bounds(-81.6475,34.9839, -90.3107,
36.6792); bFlag=true;
break;
case "TX":
state_bounds = new OpenLayers.Bounds(-93.5087, 25.838, -106.646,
36.5034); bFlag=true;
break;
case "UT":
state_bounds = new OpenLayers.Bounds(-109.041,36.9986, -114.054,
42.0042); bFlag=true;
break;
case "VT":
state_bounds = new OpenLayers.Bounds(-71.4677,42.7276, -73.4434,
45.0163); bFlag=true;
break;
case "VA":
state_bounds = new OpenLayers.Bounds(-75.2407,36.5391, -83.6748,
39.4666); bFlag=true;
break;
case "WA":
state_bounds = new OpenLayers.Bounds(-116.913,45.5531, -124.756,
49.0036); bFlag=true;
break;
case "WV":
state_bounds = new OpenLayers.Bounds(-77.7197,37.2028, -82.6408,
40.6386); bFlag=true;
break;
case "WI":
state_bounds = new OpenLayers.Bounds(-86.2496,42.4947, -92.8854,
47.3025); bFlag=true;
break;
case "WY":
state_bounds = new OpenLayers.Bounds(-104.052,40.9963, -111.055,
45.0042); bFlag=true;
break;
}
if(bFlag==true){
//state_bounds = state_bounds.transform(map.displayProjection,
map.getProjectionObject());
state_bounds = state_bounds.transform(new
OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
map.zoomToExtent(state_bounds, true);
}
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Zooming-functionality-in-OpenLayers-for-Openstreet-maps-tp4994870.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list