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

问题描述 投票:0回答:1

我用。读了一个* .geojson文件

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

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

问候,不知道

leaflet styles geojson
1个回答
1
投票
  • 然后,pointToLayer回调函数在所有Point GeoJSON特性上运行
  • style函数运行在所有LineStringPolygon GeoJSON功能上,然后
  • onEachFeature回调函数在两个点(现在是L.Markers)和线串/多边形(现在是L.Polylines和L.Polygons)上运行。

请注意,pointToLayerstyle将GeoJSON特征作为输入,而onEachFeature也采用L.Layer的实例。 L.Layer可以来自pointToLayer回调,也可以来自style回调的信息。

© www.soinside.com 2019 - 2024. All rights reserved.