用于描述地理空间信息的数据格式,语法是基于 JSON 格式的。
每一个 GeoJSON 对象都有一个 type
属性:
- Point:点
- MultiPoint:多点
- LineString:线
- MultiLineString:多线
- Polygon:面
- MultiPolygon:多面
- GeometryCollection:几何体集合
- Feature:特征
- FeatureCollection:特征集合
分类
-
type:Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon
则该对象必须有属性
coordinates
,这类对象称为几何对象。// 点对象 { 'type': 'Point', 'coordinates': [-105, 39] } // 线对象 { 'type': 'LineString', 'coordinates': [[-105, 39], [-107, 38]] } // 面对象 { 'type': 'Polygon', 'coordinates': [ [[30, 0], [31, 0], [31, 5], [30, 5], [30, 0]] ] }
-
type:GeometryCollection
则该对象必须有属性
geometries
,其值是一个数组,每一项都是一个 GeoJSON 的几何对象。{ 'type': 'GeometryCollection', 'geometries': [ { 'type': 'Point', 'coordinates': [100, 40] }, { 'type': 'LineString', 'coordinates': [[100, 30], [100, 35]] } ] }
-
type:Feature
则该对象必须有属性
geometry
,其值为一个几何对象;此外还有一个属性properties
,可以是任意 JSON 或 null{ 'type': 'Feature', 'properties': { 'name': '北京' }, 'geometry': { 'type': 'Point', 'coordinates': [116.3671875, 39.977120098439634] } }
-
type:FeatureCollection
则该对象必须有属性
features
,其值为一个数组,每一项都是一个 Feature 对象。{ 'type': 'FeatureCollection', 'features': [ { 'type': ..., 'properties': ..., 'geometry': ... }, ... ] }
参考
- 《精通D3.js:交互式数据可视化高级编程》
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。