Javascript Openlayers绘制交互:错误:单击后拖放地图
我正在尝试将绘图交互添加到地图中。用户应单击按钮,添加一个点,然后添加关于该点的属性信息。我仍然停留在绘图部分:在地图中绘制点后,光标位置保持不变,鼠标移动会在背景中更改地图(如平移)。当我再次单击时,此操作停止。不知道它为什么这么做。在Chrome的控制台中,我在openlayers的draw.js文件中得到了一个错误(this.source_u2;.addFeature不是一个函数) 谢谢你的帮助 这是我的密码:Javascript Openlayers绘制交互:错误:单击后拖放地图,javascript,openlayers,draw,Javascript,Openlayers,Draw,我正在尝试将绘图交互添加到地图中。用户应单击按钮,添加一个点,然后添加关于该点的属性信息。我仍然停留在绘图部分:在地图中绘制点后,光标位置保持不变,鼠标移动会在背景中更改地图(如平移)。当我再次单击时,此操作停止。不知道它为什么这么做。在Chrome的控制台中,我在openlayers的draw.js文件中得到了一个错误(this.source_u2;.addFeature不是一个函数) 谢谢你的帮助 这是我的密码: function addFeature() {
function addFeature() {
var btn_cancel = document.getElementById('buttonCancel');
btn_cancel.style.display = 'block';
var btn_add = document.getElementById('buttonAdd');
btn_add.classList.add("button_clicked");
var draw;
function addInteraction() {
draw = new ol.interaction.Draw({
source: lunchvec,
type: "Point",
});
map.addInteraction(draw);
draw.on('drawend', function(evt) {
console.log(evt.feature.getGeometry().getCoordinates());
map.removeInteraction(draw);
});
};
addInteraction();
}