我正在使用jQuery和jQuery UI开发JavaScript中的Openlayers工具栏。
我想要实现的一个功能是将点添加到地图上。
在OpenLayers中,您必须监听名为“sketchcomplete”的事件。
layer.events.on({
'sketchcomplete': onPointAdded
});
问题出现在onPointAdded回调函数中。该回调应返回true或false。True表示该点应添加到地图上,false表示取消将此点添加到地图上。
现在回调函数的代码如下所示:
onPointAdded = function(feature) {
var f = feature.feature;
var result = false;
$('#dialog-point-add').dialog({
modal : true,
buttons : {
'Add point' : function() {
result = true;
$(this).dialog("close");
},
'Cancel' : function() {
result = false;
$(this).dialog("close");
}
}
});
return result;
};
问题是该对话框不会阻塞执行代码。我想问您如何处理这种情况?我希望向用户显示一个确认添加点的对话框。