TransWikia.com

OpenLayers Scale Line not showing on the map

Geographic Information Systems Asked by UzmakiAshim on January 12, 2021

I am trying to generate a scale line on my map using ScaleLine but it is not showing on the map.

//Scale
import {defaults as defaultControls, ScaleLine} from 'ol/control';

map = new Map({
      target: 'map-container',
      controls: defaultControls().extend([
        new ScaleLine()
      ]),
      layers: [
        new TileLayer({
          source: new OSM()
        })
      ],
      view: new View({
        projection: 'EPSG:4326',
        center: [114.190750, 22.339914],
        zoom: 12,
        minZoom: 12,
      }),
    });

One Answer

Maybe openLayers css for scaling is not imported, or overwritten. try importing this style into your header and see if it worked.

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.1.1/css/ol.css" type="text/css">

Answered by Pedro Carvalho on January 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP