2017-07-13 22 views
0

我使用小册子在地图上创建圆圈(geojson)。圆形展示中心与小册子

pointToLayer: function (feature, latlng){ 
    if (feature.properties.radius) { 
     return new L.Circle(latlng, feature.properties.radius); 
    } 
} 

如何显示这些圆的中心?

谢谢!

+0

你愿意你的意思是什么细说“显示这些圈子的中心'? –

+0

在这张照片 - > http://www.carto-sig.com/demo/circle.png我设法做了1,但我想要做的如图2。 显示圆的中心。 – Matthieu

回答

0

您实际上可以在pointToLayer Leaflet GeoJSON选项中返回Layer Group

因此,你可以建立自己的圈子在你的代码+标记(或任何你想要的,象征你的心):

L.geoJSON(geoJsonData, { 
    pointToLayer: function (feature, latlng){ 
    if (feature.properties.radius) { 
     //return new L.Circle(latlng, feature.properties.radius); 
     return L.layerGroup([ 
     L.circle(latlng, feature.properties.radius), 
     L.marker(latlng) // or whatever symbol for circle center 
     ]); 
    } 
    } 
}).addTo(map); 

演示:http://playground-leaflet.rhcloud.com/detaw/1/edit?html,output

+0

谢谢你的回答,但用这种技巧我不能再用Leaflet Draw修改圆圈。 – Matthieu

+0

这应该是一个新问题。你现在没有提到它。 – ghybs