My problem lies firstly with the fact that I don“t know how to calculate
the map resolution. Also what is the relationship between maxResolution,
maxExtent, restricted extent and setting a mapcenter?

It was confusing to me at first. But if you're impatient, I'd say this:

Start here and copy it:
http://openlayers.org/dev/examples/web-mercator.html

For more dense reading:
http://docs.openlayers.org/library/spherical_mercator.html

The short version:

* The maxExtent etc. are set in the Map's constructor by passing options, just like in that example. The maxExtent and maxResolution must match up in any case, and in Google's case you can consider them universal constants.

* You are correct to use restrictedExtent instead of maxExtent, to force the map to stay in that area.

* If you really want to know what resolutions are and what a max-resolution really means, feel free to ask again. If you just want your map to work, you don't need to know the math.



4. If I want to setcenter, which of these property need to be taken
away? I could see that in order the setcenter, the restrictedExtents
might need to be removed..but is there a "best practice" way of doing
these things?

You're doing it right: restrictedExtent and then setCenter().

If you're saying that the map doesn't recenter when you call setCenter(), I would check whether your new center is in fact inside your restrictedExtent. I don't see the setCenter() call in your code there, so can't say.

Option A: If you want to zoom to the restrictedExtent, you can use this shortcut:
  map.zoomToMaxExtent()
Due to the restrictedExtent, this won't in fact zoom to the whole world but only to your restriction.

Option B: Use this quick trick to do some reprojection, and see if your extent looks right:

var sw = new OpenLayers.Bounds(-120,34,-100,54);
var lonlat = new OpenLayers.Projection('EPSG:4326');
var google = new OpenLayers.Projection('EPSG:900913');
alert( sw.transform(lonlat,google) );

--
Greg Allensworth
Web GIS Developer, GreenInfo Network
BS  A+  Network+  Security+  Linux+  Server+
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to