如何通过在Leaflet.FileLayer中加载KML来获取FeatureCollection

时间:2018-09-28 14:58:01

标签: javascript leaflet geojson

我正在将kml文件加载到地图中,并使用Leaflet.FileLayer插件显示此多边形。我想将所有的kml数据转换成geojson格式。这是我的代码:

var layer = L.Control.fileLayerLoad({
                        fitBounds: true,
                        layerOptions: {
                            style: style,
                            onEachFeature: onEachFeature,
                            pointToLayer: function (data, latlng) {
                                return L.circleMarker(
                                    latlng, {
                                        style: style
                                    }
                                );
                            }
                        }
                    }).addTo(map);
                }

                function onEachFeature(feature, layer) {
                    $log.info("FEATURE",feature,"LAYER",layer);
                    // does this feature have a property named popupContent?
                    if (feature.properties && feature.properties.popupContent) {
                        layer.bindPopup(feature.properties.popupContent);
                    }
                }

我已经看到onEachFeature()给出了一层一层的信息,但是我需要一个完整的数据。有人可以告诉我,有什么简单的方法可以找到Leaflet.FileLayer这个信息吗?

0 个答案:

没有答案