Accessing Topojson features

المشرف العام

Administrator
طاقم الإدارة
I am having trouble with accessing the "density" property of my TopoJSON file. Basically I want to change the density property or add another property named "metric" in my properties and make the choropleth on the basis of these properties.

Here is my code

$.getJSON(url, function(data) {var geojsonData = topojson.feature(data, data.objects.test);$.each(geojsonData.features, function(key, val) { val.properties.density = population[key]; var geojsonLayer = new L.geoJson(geojsonData, { style: getStyle,}).addTo(map);});});If anyone can point out what am I doing wrong here, it will be really helpful

Here is the TopoJSON I am using

{"type":"Topology","objects":{"test":{"type":"GeometryCollection","geometries":[{"type":"Polygon","id":"01","properties":{"name":"Alabama","density":94.65},"arcs":[[-1,-2,-3,-4,-5]]},{"type":"MultiPolygon","id":"02","properties":{"name":"Alaska","density":1.264},"arcs":[[[-6]],[[-7]],[[-8]],[[-9]],[[-10]],[[-11]],[[-12]],[[-13]],[[-14]],[[-15]],[[-16]],[[-44]]]},{"type":"Polygon","id":"04","properties":{"name":"Arizona","density":57.05},"arcs":[[-45,-46,-47,-48,-49]]}

أكثر...
 
أعلى