用于描述地理空间信息的数据格式,语法是基于 JSON 格式的。编程
每个 GeoJSON 对象都有一个 type
属性:数组
type:Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygoncode
则该对象必须有属性 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:GeometryCollectionio
则该对象必须有属性 geometries
,其值是一个数组,每一项都是一个 GeoJSON 的几何对象。class
{ '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': ... }, ... ] }