如何在Leaflet地图上打印/显示/绘制MultiPolygon GeoJSON

时间:2015-05-18 17:47:02

标签: javascript angularjs leaflet geojson

我正在尝试在Leaflet地图中显示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的其他层。

1 个答案:

答案 0 :(得分:3)

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

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