I want to create a snap control of my layer. My simple example demo is here
var raster = new ol.layer.Tile({
source: new ol.source.OSM({
})
});
var source = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: 'https://raw.githubusercontent.com/openlayers/ol3/6838fdd4c94fe80f1a3c98ca92f84cf1454e232a/examples/data/geojson/countries.geojson'
})
// vector layer
var vector = new ol.layer.Vector({
source: source,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#eedd00',
width: 1.5
})
})
});
// render the map
var map = new ol.Map({
target: 'map',
renderer: 'canvas',
layers: [raster, vector],
view: new ol.View({
center: [0, 0],
zoom: 1
})
});
var snap = new ol.interaction.Snap({
source: source
});
map.addInteraction(snap);
snap.setActive(true);
I activated the snap interaction but it does not snap vectors