Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import GeoJSON from 'ol/format/GeoJSON';
import GeometryType from 'ol/geom/GeometryType';
import {DragAndDrop, Draw, Modify, Snap} from 'ol/interaction';
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import sync from 'ol-hashed';
const map = new Map({
target: 'map-container',
view: new View({
center: [0, 0],
zoom: 2
})
});
sync(map);
const source = new VectorSource();
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
map.addInteraction(new DragAndDrop({
source: source,
formatConstructors: [GeoJSON]
}));
map.addInteraction(new Modify({
source: source
}));
layers: [
new VectorLayer({
source: new VectorSource({
format: new GeoJSON(),
url: './data/countries.json'
})
})
],
view: new View({
center: [0, 0],
zoom: 2
})
});
//! [sync]
sync(map);
//! [sync]
import Snap from 'ol/interaction/Snap';
//! [import-snap]
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import View from 'ol/View';
import sync from 'ol-hashed';
const map = new Map({
target: 'map-container',
view: new View({
center: [0, 0],
zoom: 2
})
});
sync(map);
const source = new VectorSource();
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
map.addInteraction(new DragAndDrop({
source: source,
formatConstructors: [GeoJSON]
}));
map.addInteraction(new Modify({
source: source
}));
import Modify from 'ol/interaction/Modify';
//! [import-modify]
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import View from 'ol/View';
import sync from 'ol-hashed';
const map = new Map({
target: 'map-container',
view: new View({
center: [0, 0],
zoom: 2
})
});
sync(map);
const source = new VectorSource();
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
map.addInteraction(new DragAndDrop({
source: source,
formatConstructors: [GeoJSON]
}));
//! [modify]
map.addInteraction(new Modify({
source: source
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import View from 'ol/View';
import sync from 'ol-hashed';
//! [map-const]
const map = new Map({
//! [map-const]
target: 'map-container',
view: new View({
center: [0, 0],
zoom: 2
})
});
sync(map);
//! [source]
const source = new VectorSource();
//! [source]
//! [layers]
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
//! [layers]
//! [interaction]
map.addInteraction(new DragAndDrop({
source: source,
formatConstructors: [GeoJSON]
import Map from 'ol/Map';
import Modify from 'ol/interaction/Modify';
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import View from 'ol/View';
import sync from 'ol-hashed';
const map = new Map({
target: 'map-container',
view: new View({
center: [0, 0],
zoom: 2
})
});
sync(map);
const source = new VectorSource();
const layer = new VectorLayer({
source: source
});
map.addLayer(layer);
map.addInteraction(new DragAndDrop({
source: source,
formatConstructors: [GeoJSON]
}));
map.addInteraction(new Modify({
source: source
}));
const f = Math.pow(clamp((area - min) / (max - min), 0, 1), 1 / 2);
const index = Math.round(f * (steps - 1));
return ramp[index];
}
//! [color]
const map = new Map({
target: 'map-container',
view: new View({
center: [0, 0],
zoom: 2
})
});
sync(map);
const source = new VectorSource();
//! [style]
const layer = new VectorLayer({
source: source,
style: function(feature) {
return new Style({
fill: new Fill({
color: getColor(feature)
}),
stroke: new Stroke({
color: 'rgba(255,255,255,0.8)'
})
});
}