How to use ol-layerswitcher - 2 common examples

To help you get started, we’ve selected a few ol-layerswitcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mapgears / ol3-google-maps / examples / archived / layerswitcher.js View on Github external
interactions: defaultInteractions(),
  layers: [
    googleLayer,
    osmLayer
  ],
  target: 'map',
  view: new View({
    center: center,
    zoom: 12
  })
});

const olGM = new OLGoogleMaps({map: map}); // map is the Map instance
olGM.activate();

const layerSwitcher = new LayerSwitcher();
map.addControl(layerSwitcher);
github camptocamp / ngeo / api / src / Map.js View on Github external
this.map_.addControl(new MousePosition({
        coordinateFormat: createStringXY(0)
      }));
    }
    if (options.addMiniMap) {
      this.map_.addControl(new OverviewMap({
        collapsed: !options.miniMapExpanded,
        view: new View({
          projection: this.view_.getProjection(),
          resolutions: this.view_.getResolutions()
        })
      }));
    }

    if (options.addLayerSwitcher) {
      this.map_.addControl(new LayerSwitcher());
    }

    // Get background layer first...
    themes.getBackgroundLayers().then((layers) => {
      // The options is an array for backward compatibility reason.
      const backgroundLayer = options.backgroundLayers || [constants.backgroundLayer];
      for (const layer of layers) {
        if (backgroundLayer.includes(layer.get('config.name'))) {
          // we don't want the background layer in the layerswitch so we remove the title.
          layer.set('title', undefined);
          this.map_.addLayer(layer);
        }
      }

      // ... then get overlay layers (if defined)
      const overlayLayerNames = options.layers;

ol-layerswitcher

Layer switcher control for OpenLayers

MIT
Latest version published 4 months ago

Package Health Score

65 / 100
Full package analysis

Popular ol-layerswitcher functions