我试图使用自定义geojson文件在HighMaps中创建人口的chloropleth地图。使用geojson文件在HighMaps中添加Maplines
我有2个geojson文件 - 第一个包含县级数据,第二个包含县内包含的较小的城镇地区。
我想县级边框添加到我的类似于此示例chloropleth地图:http://www.highcharts.com/maps/demo/us-counties
我能够得到的小区域用适当的颜色渐变正确打印;但是我的地图上没有出现县界线。
我的js代码如下:
$(function() {
$.getJSON('population.json', function(data) {
$.getJSON('smaller_areas.geojson', function(geojson) {
$.getJSON('counties.geojson', function(maplines){
// Initiate the chart
Highcharts.mapChart('container', {
chart: {
width: 600,
borderWidth: 1
},
title: {
text: 'Population'
},
legend: {
title: {
text: 'Crime Rates',
style: {
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
}
},
align: 'right',
verticalAlign: 'top',
floating: true,
layout: 'vertical',
valueDecimals: 0,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || 'rgba(255, 255, 255, 0.85)',
symbolRadius: 0,
symbolHeight: 14
},
mapNavigation: {
enabled: true,
enableDoubleClickZoomTo: true
},
colorAxis: {
min: 1,
type: 'logarithmic',
minColor: '#EEEEFF',
maxColor: '#000022',
stops: [
[0, '#EFEFFF'],
[0.67, '#4444FF'],
[1, '#000022']
]
},
series: [{
data: data,
mapData: geojson,
joinBy: ['GEOGID', 'GEOGID'],
name: 'Population',
tooltip: {
pointFormat: '{point.Name}: {point.value}'
}
},
{
type: 'mapline',
name: 'County Borders',
Data: maplines,
color: 'black',
lineWidth: 10
}]
});
});
});
});
});
我假设,我将需要修改的maplines系列的“数据”命令,由于我来自一个GeoJSON的文件中读取的事实;但我不知道如何做到这一点。
我为县数据以GeoJSON看起来是这样的: { “类型”: “的FeatureCollection”, “CRS”:{ “类型”: “名字”, “属性”:{ “名称” 为“urn: ogc:def:crs:EPSG :: 3857“}}, ”features“:[ {”type“:”Feature“,”properties“:{”COUNTYNAME“:”Leitrim“},”geometry“类型“:”MultiPolygon“,”coordinates“:[[[[-925332.1353,7260461.4174],[-925231.9477,7260212.372],[-925020.4407,7260020.804],[-924719.8781,7259925.0218],[-924597.4266,7259886.7092],
其次是该县及其后县的其余预测。
任何人都可以帮忙吗?
在此先感谢。
数据应以小写字母开头。你可以在jsfiddle/codepen/etc上重新创建问题吗?你可以粘贴json contect,这样它就不会使用ajax调用。 – morganfree