Skip to content

new control to build legend from openlayer sources

Notifications You must be signed in to change notification settings

SDaron/olLegend

Repository files navigation

Ol Legends

New control for openlayer, building legend from sources.

Test example

git clone [email protected]:SDaron/olLegend.git
npm start

Usage

import {Map, View} from 'ol';
import {Fill, Stroke, Style} from 'ol/style';
import {Vector as VectorSource} from 'ol/source.js';
import {Vector as VectorLayer} from 'ol/layer.js';
import controlLegend from './Legend.js';
import './legend.css';


const layer = new VectorLayer({
  source: new VectorSource({
  }),
});

layer.getSource().set('title',"Hydrologie");
layer.getSource().getLegends = function(){
    const legends = [
      {
        label:'bassin versant',
        geometry: 'Polygon',
        style:new Style({
          fill: new Fill({color: 'white'}),
          stroke: new Stroke({color: 'red', width: '2'}),
        })        
      },
      {
        label:'rivière',
        geometry: 'LineString',
        style:new Style({
          stroke: new Stroke({color: 'red', width: '2'}),
        })        
      }
    ];
    return legends;
};
const map = new Map({
  controls:[olLegend],
  layers: [layer],
  target: 'map'
});

About

new control to build legend from openlayer sources

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published