[OpenLayers-Users] Scale Line displays NaN

Mark Paxton mark at innaxys.com
Thu Sep 27 09:00:02 PDT 2012


Hi all,

I'm having an issue displaying a scale line for my Geoserver WMS
layer... for OSM it dusplays OK, but with the WMS layer it just displays
NaN.  Below is how I set up the map... any help is appreciated!

Regards,
Mark

var map;
var maplayers = new Array();

var webMerc = new OpenLayers.Projection("EPSG:900913");
var sphericalMerc = new OpenLayers.Projection("EPSG:3857");
var wgs84 = new OpenLayers.Projection("EPSG:4326");

OpenLayers.DOTS_PER_INCH = 90.71428571428572;
OpenLayers.Util.onImageLoadErrorColor = 'transparent';
var bounds = new OpenLayers.Bounds(-7.5, 49.9600, 1.7800, 60.8400); //
Limit to OSGB36
var options = {
        resolutions: [156543.03390625, 78271.516953125,
39135.7584765625, 19567.87923828125, 9783.939619140625,
4891.9698095703125, 2445.9849047851562, 1222.9924523925781,
611.4962261962891, 305.74811309814453, 152.87405654907226,
76.43702827453613, 38.218514137268066, 19.109257068634033,
9.554628534317017, 4.777314267158508, 2.388657133579254,
1.194328566789627, 0.5971642833948135, 0.29858214169740677,
0.14929107084870338, 0.07464553542435169, 0.037322767712175846,
0.018661383856087923, 0.009330691928043961, 0.004665345964021981,
0.0023326729820109904, 0.0011663364910054952, 5.831682455027476E-4,
2.915841227513738E-4, 1.457920613756869E-4],
        projection: sphericalMerc,
        displayProjection: wgs84,
        maxExtent: new
OpenLayers.Bounds(-2.003750834E7,-2.003750834E7,2.003750834E7,2.003750834E7),
        units : "meters"
    };
      
    map = new OpenLayers.Map('map', options);
    map.setOptions({
        restrictedExtent : bounds
    });
   
    /* This is the remote Open Street Map layer */
    maplayers['osm'] = new OpenLayers.Layer.OSM("OSM");
    map.addLayer(maplayers['osm']);
   
    maplayers['basemaps'] = new OpenLayers.Layer.WMS(
        "basemaps","http://192.168.47.130:8080/geoserver/gwc/service/wms", {
            layers: 'basemaps',
            format: 'image/png'
            },
        { tileSize: new OpenLayers.Size(256,256)}
    );
    map.addLayer(maplayers['basemaps']);
   
    map.addControl(new OpenLayers.Control.Navigation());
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.addControl(new OpenLayers.Control.ScaleLine({geodesic: false}));
    map.addControl(new OpenLayers.Control.LoadingPanel());
   


More information about the Users mailing list