How to set the radius of a circle marker to be proportional to an attribute value?

天大地大妈咪最大 提交于 2020-01-11 14:31:07

问题


So I am making a Leaflet map. I am using a json which lists countries as Latlng points, and their corresponding attribute (called CTH values). I am trying to use this value to set the radius of circle markers on these Latlng points, but I am struggling to figure out how.

This is what I've written

function addCTHValueMarkers () {

 CTHValueLayer = L.geoJSON(CTHValue,  {
                        pointToLayer: function (feature, latlng) {
                            return new L.circleMarker(latlng, {
                            fillOpacity: 0.6,
                            radius: setRadius(feature.properties.CTHValue)
                           })
                        }
 });

 CTHValueLayer.addTo(map);
}

I tried to make a seperate SetRadius function, as you can see referenced above, but I don't quite know what to put inside. I just want the radius to set as the CTHValue / some function of the CTH value. How should I do this?

来源:https://stackoverflow.com/questions/59401891/how-to-set-the-radius-of-a-circle-marker-to-be-proportional-to-an-attribute-valu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!