私は OpenLayers3 を使用しており、ユーザーが 1 つ以上のポイントを描画できるマップが必要です。私はすでにそれを実装しました。ただし、すべてのポイントの座標も保存したいと思います。
しかし、OpenLayers3 はかなり新しく、オンラインで例を見つけるのに苦労しているため、その方法がよくわかりません。
これは私がこれまでに持っているものです:
var modeSelect = document.getElementById('type');
var draw; // global so we can remove it later
//modify
var featureOverlay = new ol.FeatureOverlay({
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)'
}),
stroke: new ol.style.Stroke({
color: '#ffcc33',
width: 2
}),
image: new ol.style.Circle({
radius: 7,
fill: new ol.style.Fill({
color: '#ffcc33'
})
})
})
});
featureOverlay.setMap(map);
// modify end
function addInteraction() {
var value = modeSelect.value;
if (value == 'Point') {
draw = new ol.interaction.Draw({
//source: source,
features: featureOverlay.getFeatures(),
type: /** @type {ol.geom.GeometryType} */ (value)
});
map.addInteraction(draw);
}
// modify
if (value == 'Modify') {
var modify = new ol.interaction.Modify({
features: featureOverlay.getFeatures(),
// the SHIFT key must be pressed to delete vertices, so
// that new vertices can be drawn at the same position
// of existing vertices
deleteCondition: function(event) {
return ol.events.condition.shiftKeyOnly(event) &&
ol.events.condition.singleClick(event);
}
});
map.addInteraction(modify);
}
}
addInteraction();