[OpenLayers-Users] OSM (OpenStreetMap) layer and controlled zoom levels

del cadarn del_cadarn at hotmail.com
Fri Sep 2 04:07:46 EDT 2011


Hello,

I know this is an issue that was raised a few years ago - I noticed a few posts in 2007 - but I wonder if there is now solutions that I am not aware of.

I'm trying to limit extent and zoom levels of a map including Bing and OSM basemaps. I succeed to get to do what I want for the Bing side of things but I keep getting errors with the OSM layer... either I can't get it to show up at all or it won't restrict the extent and the zooms.

here is the relevant portion of code (I'll also put below a few variants I tried for the OSM layer)

  map = new OpenLayers.Map('map_element', {
        maxExtent: new OpenLayers.Bounds(
            -504904.79024762,
            7109446.218042,
            -138007.0545445,
            7476343.9537452),
        units: 'm',
        projection: new OpenLayers.Projection('EPSG:900913'),
        maxResolution: 611.496226171875,
        numZoomLevels: 10
        });

// Basemaps
    //Bing            

        var ve_road = new OpenLayers.Layer.VirtualEarth(
        'Bing Road',
        {sphericalMercator:true}
        );

        var ve_aerial = new OpenLayers.Layer.VirtualEarth(
        'Bing Aerial',
        {type: VEMapStyle.Aerial,
        sphericalMercator:true}
        );

    //OpenStreetMap

            var osm_layer = new OpenLayers.Layer.OSM(
        'OpenStreetMap Layer',
        ' ',
        {sphericalMercator:true,
        maxResolution: 611.496226171875,
        numZoomLevels: 10}
        );

now for the osm_layer I have also tried (which doesn't work either)
        var osm_layer = new OpenLayers.Layer.OSM(

        'OpenStreetMap Layer',

        {sphericalMercator:true,

        maxResolution: 611.496226171875,

        numZoomLevels: 10}

        );

and (which works but doesn't limit the zooms)

        var osm_layer = new OpenLayers.Layer.OSM(


        'OpenStreetMap Layer'


        );

I know I'm doing something wrong somewhere and there are faults in my code... Could anyone help me?

                                        Thank you,

                                                 Delphine

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110902/a51d7508/attachment.html


More information about the Users mailing list