首页 > 解决方案 > 将模态值传递给 GeoJSON

问题描述

一旦用户点击 X,我正在尝试将值从模式传递到 GeoJason 属性你介意推荐我或帮助我修复代码吗

模态代码是

<div id="myModal" class="modal">
  <!-- Modal content -->
  <div class="modal-content">
    <span class="close">&times;</span>
    <input type="text" id="myText" value="Some text...">
  </div>

</div>

地图点击功能是

function onMapClick(e) {
    modal.style.display = "block";
     var geojsonFeature = {
        "type": "Feature",
            "properties": {},
            "geometry": {
                "type": "Point",
                "coordinates": [e.latlng.lat, e.latlng.lng]
        }
    }

    var marker;

    L.geoJson(geojsonFeature, {

        pointToLayer: function(feature, latlng){
            
            marker = L.marker(e.latlng, {
                
                title: "Resource Location",
                alt: "Resource Location",
                riseOnHover: true,
                draggable: true,

            }).bindPopup("<input type='button' value='Delete this marker' class='marker-delete-button'/>");

            marker.on("popupopen", onPopupOpen);
       
            return marker;
        }
    }).addTo(map);
    
 
}

关闭模态功能代码是

span.onclick = function() {
  modal.style.display = "none";
}

标签: javascriptleaflet

解决方案


推荐阅读