[OpenLayers-Users] Setting layer maxResolution and numZoomLevels
rickm81
rickm81 at yahoo.com
Fri Apr 5 08:54:34 PDT 2013
I'm new to OpenLayers and experiencing some trouble with setting
maxResolution and numZoomLevels on a layer. I would like the max value to be
lesser (more zoomed in) than the default value.
The code below is a simple map init function. I have tried setting the
maxResolution, maxScale, and numZoomLevel properties in both the map and
layer constructors with no luck. The line that is commented out was a
suggestion on another forum that seemed to work, but I was not able to
change these values to something that would work for me.
var EPSG4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG900913 = new OpenLayers.Projection("EPSG:900913");
var newbounds = new OpenLayers.Bounds(-20037508.3427892,
-20037508.3427892, 20037508.3427892, 20037508.3427892);
var lat = 42.68;
var lon = -71.409;
var zoom = "10";
var centre = new OpenLayers.LonLat(lon, lat).transform(EPSG4326,
EPSG900913)
var extent = newbounds.transform(EPSG4326, EPSG900913);
var map;
function init() {
map = new OpenLayers.Map("map", {
controls: [
new OpenLayers.Control.MouseDefaults(),
new OpenLayers.Control.Permalink(),
new OpenLayers.Control.PanZoomBar()],
displayProjection: new
OpenLayers.Projection("EPSG:4326"),
});
//var OSMLayer = new OpenLayers.Layer.OSM(("OSM"),"",{
isBaseLayer: true, zoomOffset: 11, resolutions: [76.4370282714844,
38.2185141357422, 19.1092570678711, 9.55462853393555, 4.77731426696777,
2.38865713348389, 1.19432856674194] });
var OSMLayer = new OpenLayers.Layer.OSM("OSM");
map.addLayer(OSMLayer);
map.addControl(new OpenLayers.Control.Attribution());
map.addControl(new OpenLayers.Control.KeyboardDefaults());
map.setOptions({ restrictedExtent: extent })
if (!map.getCenter()) { map.setCenter(new
OpenLayers.LonLat(lon, lat).transform(EPSG4326, EPSG900913), zoom); }
I am working in .NET MVC 4. Are there any known issues in Open Layers with
this framework or with OSM? It seems easy enough to define these properties,
but I am having all kinds of problems. Any help would be much appreciated.
Thanks!
Rick
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Setting-layer-maxResolution-and-numZoomLevels-tp5044883.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list