读取* geojson文件的style-和onEachFeature函数之间有什么区别

时间:2019-02-26 20:21:08

标签: leaflet styles geojson

我读取了* .geojson文件

$.ajax(overlay).done(function(data) {
    data = JSON.parse(data);
    L.geoJson(data, {
            pointToLayer: pointToLayer,
            style: style,
            onEachFeature: onEachFeature
    });
return});

据我了解(新手),对于文件中的每个标记,将处理pointToLayer-函数,对于每个多边形和线串,将处理样式函数和onEachFeature函数。对? 最后两个函数(不考虑名称)有什么区别?

粗鲁,眨眼

1 个答案:

答案 0 :(得分:1)

  • pointToLayer回调函数可在所有Point GeoJSON功能上运行,然后
  • style函数可在所有LineStringPolygon GeoJSON功能上运行,然后
  • onEachFeature回调函数在两个点(现在为L.Marker s)和以及线串/多边形(现在为L.Polyline s)上运行和L.Polygon s)。

请注意,pointToLayerstyle采用GeoJSON功能作为输入,而onEachFeature也采用L.Layer的实例。 L.Layer可以来自 pointToLayer回调,也可以来自style回调内部。

相关问题