2017-07-13 23 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