jquery 传单-使用Map范围的BBox从API刷新GeoJSON图层

6yoyoihd  于 2023-05-17  发布在  jQuery
关注(0)|答案(1)|浏览(173)

我正在尝试从OGCAPI-Features endpoint添加GeoJSON层。
该层具有> 59 k的特征,因此我使用limit=100,但我需要Map在用户平移/缩放Map时基于Map范围刷新GeoJSON。
我做了一个开始和uit加载前100个功能,但它不刷新所需的。
有什么建议吗?

(async () => {
    const agsboreholes = await fetch('https://ogcapi.bgs.ac.uk/collections/agsboreholeindex/items?bbox=' + map.getBounds().toBBoxString() + '&limit=100', {
      headers: {
        'Accept': 'application/geo+json'
      }
    }).then(response => response.json());
    L.geoJSON(agsboreholes, {
      onEachFeature: onEachFeature
    }).addTo(map);
})();    

function onEachFeature(feature, layer) {
    var popupContent = "<b>AGS Borehole Information</b><br><hr>" +
            "<b>BGS LOCA ID: </b>" + feature.properties.bgs_loca_id + "<br>" +
            "<b>Depth (m): </b>" + feature.properties.loca_fdep + "<br>" +
            "<b>Project Name: </b>" + feature.properties.proj_name + "<br>" +
            "<b>Project Engineer: </b>" + feature.properties.proj_eng + "<br>" +
            "<b>Project Contractor: </b>" + feature.properties.proj_cont + "<br>" +
            "<b>Original LOCA ID: </b>" + feature.properties.loca_id + "<br>" +
            "<b>AGS Graphical Log: </b>" + "<a href=" + "https://agsapi.bgs.ac.uk/ags_log/?bgs_loca_id=" + feature.properties.bgs_loca_id + " target=" + "_blank" + ">View</a>" + "<br>" +
            "<b>AGS Data: </b>" + "<a href=" + "https://agsapi.bgs.ac.uk/ags_export/?bgs_loca_id=" + feature.properties.bgs_loca_id + " target=" + "_blank" + ">Download</a>" + "<br>" +
            "<b>AGS Submission Record (raw data): </b>" + "<a href=" + feature.properties.dad_item_url + " target=" + "_blank" + ">View</a>" + "<br>";
    if (feature.properties && feature.properties.popupContent) {
        popupContent += feature.properties.popupContent;
    }
    layer.bindPopup(popupContent);
}
uoifb46i

uoifb46i1#

GitLab上提供的答案
“我用

var l_ogc = L.featureGroup.ogcApi(url, { collection: 'kreise', pane: 'overlays', limit: 400 }); l_ogc.on("ready", () => {map.addLayer(l_ogc);})

修复比赛并阅读100多个功能。”
https://gitlab.com/IvanSanchez/leaflet.featuregroup.ogcapi/-/issues/2#note_1382843053

相关问题