Leaflet 从弹出窗口收集传单(绘制创建的数据)属性,以创建要素属性

Leaflet 从弹出窗口收集传单(绘制创建的数据)属性,以创建要素属性,leaflet,geojson,leaflet.draw,Leaflet,Geojson,Leaflet.draw,我已经阅读了@ghybs页面给出的有用的回答:“我已经读过了。” 但我仍然坚持使用一个引导弹出窗口来让它工作,从用户那里收集数据并保存在feature.properties上。稍后,我将从多个标记中收集多个数据,多边形多段线转换为geojson。 我可以从弹出窗口中收集数据,但我创建的每个标记的数据都显示相同。每个标记的feature.properties应该不同 请查看我的代码: var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y

我已经阅读了@ghybs页面给出的有用的回答:“我已经读过了。”

但我仍然坚持使用一个引导弹出窗口来让它工作,从用户那里收集数据并保存在feature.properties上。稍后,我将从多个标记中收集多个数据,多边形多段线转换为geojson。 我可以从弹出窗口中收集数据,但我创建的每个标记的数据都显示相同。每个标记的feature.properties应该不同

请查看我的代码:

var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib='&复制;投稿人,,
osm=L.tileLayer(osmUrl{
maxZoom:18,
署名:奥斯马特里布
});
map=L.map('map'{
层:[osm],
中间:[31.9500,35.9333],
缩放:15
});
var editableLayers=L.geoJson().addTo(map);
map.addControl(新的L.Control.Draw({
编辑:{
功能组:可编辑层
}
}));
地图上('draw:created',函数(e){
var layer=e.layer,
feature=layer.feature=layer.feature |{};
feature.type=feature.type | |“feature”;
var props=feature.properties=feature.properties | |{};
//layer.feature={properties:{};//无需转换为GeoJSON。
//var props=layer.feature.properties;
props.action=null;
editableLayers.addLayer(层);
添加弹出窗口(层);
});
功能添加弹出窗口(层){
var content=document.getElementById('action');
layer.feature.properties.action=内容;
/*content.addEventListener(“键控”,函数(){
layer.feature.properties.action=内容;
});*/
/*layer.on(“popupopen”,函数(){
content.value=layer.feature.properties.desc;
content.focus();
});
layer.bindPopup(content.openPopup()*/
layer.on('单击',函数()){
$('#action').val(layer.feature.properties.action);
//content.value=layer.feature.properties.action;
$('#attributes').modal({'show':true,背景:'static',键盘:false});
$('#action').val(layer.feature.properties.action);
});
}
document.getElementById(“转换”).addEventListener(“单击”,函数)(){
log(JSON.stringify(editableLayers.toGeoJSON(),null,2));
});
#地图{
高度:500px;
}

获取GeoJSON字符串的所有功能
属性数据
行动
好啊

我解决了这个问题,谢谢大家……我解决了这个问题,谢谢大家。。。。。。。