gpt4 book ai didi

javascript - 如何在 Leaflet map 上打印/显示/绘制 MultiPolygon GeoJSON

转载 作者:数据小太阳 更新时间:2023-10-29 05:29:35 25 4
gpt4 key购买 nike

我正在尝试在 Leaflet map 中显示 GeoJSON MultiPolygon 对象。我从 PostgreSQL 数据库中以 JSON 格式获取它,然后将其转换为 GeoJSON。

我已经在 GeoJSONLint 中验证了 de MultiPolygon 对象没关系: enter image description here

但我无法在我的应用程序中完成此操作 =(

这是我的代码:

       $http.get(URI_SERVICE+"buscar-clase/"+JSON.stringify(params))
.success(function (data) {
console.log(L.multiPolygon(data.coordinates).toGeoJSON());
adaLayer.clearLayers();
adaLayer = L.geoJson(L.multiPolygon(data.coordinates).toGeoJSON(), {
style: function () {
return {weight: 1, color: "#000000"}
}
});
adaLayer.addTo(map);
}).error(function (err) {
console.log(err);
});

郑重声明,map var 工作正常,我打印了 GeoJSON 的其他层。

最佳答案

L.geoJSON 提供整个有效载荷,而不仅仅是坐标数组。喜欢

        adaLayer = L.geoJson(data, {
style: function () {
return {weight: 1, color: "#000000"}
}
});

关于javascript - 如何在 Leaflet map 上打印/显示/绘制 MultiPolygon GeoJSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30309762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com