[OpenLayers-Users] Problem using "element" property on Scale Control

Mike Melson mike at melson.com
Thu Feb 14 18:37:50 PST 2013


Hi. Newbie to OpenLayers & I am having trouble getting the Scale control's output to show up in a separate element.

My HTML is:
<label>Lon/Lat:</label><span id="lonlat"></span>
<label>Scale:</label><span id="mapScale"></span>


My javascript is:
var map = new OpenLayers.Map('map', {
  center: new OpenLayers.LonLat(-95, 36).transform("EPSG:4326", "EPSG:900913"),
  zoom: 4,
  layers: cdvM.map.layers,
  displayProjection: "EPSG:4326",
  controls:[
    new OpenLayers.Control.Navigation(),
    new OpenLayers.Control.OverviewMap(), 
    new OpenLayers.Control.Scale({
      element 	: document.getElementById("mapScale")
    }), 
    new OpenLayers.Control.ScaleLine(),
    new OpenLayers.Control.LayerSwitcher(),
    new OpenLayers.Control.PanZoomBar(),
    new OpenLayers.Control.MousePosition({
      element 	: document.getElementById("lonlat"),
      numDigits	: 4,
      separator	: ", "
    }), 
    new OpenLayers.Control.KeyboardDefaults()
  ]
});

The MousePosition Control correctly shows in the lonlat span. 
The Scale info doesn't. I tried switching the two & the MousePosition was able to display in the Scale's span.

If this has already been answered, I apologize...I was unable to search the archives (got an error): http://lists.osgeo.org/mailman/listinfo/openlayers-users

Mike


More information about the Users mailing list