UNPKG

openlayers

Version:

Build tools and sources for developing OpenLayers based mapping applications

38 lines (32 loc) 784 B
goog.require('ol.Map'); goog.require('ol.View'); goog.require('ol.control'); goog.require('ol.control.ScaleLine'); goog.require('ol.layer.Tile'); goog.require('ol.source.OSM'); var scaleLineControl = new ol.control.ScaleLine(); var map = new ol.Map({ controls: ol.control.defaults({ attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ collapsible: false }) }).extend([ scaleLineControl ]), layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ], target: 'map', view: new ol.View({ center: [0, 0], zoom: 2 }) }); var unitsSelect = document.getElementById('units'); function onChange() { scaleLineControl.setUnits(unitsSelect.value); } unitsSelect.addEventListener('change', onChange); onChange();