有人可以解释一下为什么这个传单代码可用于可视化纽约州的GeoJson数据但我无法绘制纽约市的数据.我对QGIS中的文件使用了相同的导出首选项.
我使用了以下链接中的数据:
纽约市 http://www.nyc.gov/html/dcp/html/bytes/districts_download_metadata.shtml
纽约州 http://cugir.mannlib.cornell.edu/bucketinfo.jsp?id=7865
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<link rel="stylesheet" href="style_blank.css" />
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="sdfgsdgdfgfdsgd.js"></script>
<div id="map"></div>
<script>
var map = L.map('map',{
center: [5,28],
zoom: 3,
minZoom: 2,
maxZoom: 18
});
L.geoJson(data, {
style: function (feature) {
return {color: feature.properties.color};
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.description);
}
}).addTo(map);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
由于问题缺乏特异性,很难说出问题所在.不过,我猜得很好.
我按照您的城市数据链接下载了"Borough Boundaries"shapefile,然后将其导入QGIS.坐标单位看起来是英尺或米,表示它是投影数据.Leaflet无法处理投影坐标; 它需要未投影的纬度/经度(十进制度)坐标.您需要做的是按照以下步骤操作:
1)找出数据的投影;
2)使用GIS软件(例如免费的开源QGIS)将该投影分配给数据;
3)将数据重新投影到WGS 84(EPSG:4326)坐标参考系统;
4)将重新投影的数据保存为新的GeoJSON.
| 归档时间: |
|
| 查看次数: |
721 次 |
| 最近记录: |