geojson 学习

市面上的地图都是采用geojson来描述地图的
其基本结构如下

{
    type:"FeatureCollection",
    features:[]
}

它有如下几种类型

单点

{
    type:"FeatureCollection",
    features:[
            {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          89.6484375,
          68.13885164925573
        ]
      }
    }
    ]
}

多点

{
    type:"FeatureCollection",
    features:[
            {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "MultiPoint",
        "coordinates": [[
          89.6484375,
          68.13885164925573
        ],[
            89.6484375,
          78.13885164925573
        ]]
      }
    }
    ]
}

线

单条线

在坐标的描述结构和点类似,只是type有所区别

{
    type:"FeatureCollection",
    features:[
            {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type":"LineString",
        "coordinates": [[
          89.6484375,
          68.13885164925573
        ],[
            89.6484375,
          78.13885164925573
        ]]
      }
    }
    ]
}

多条线

{
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "MultiLineString",
        "coordinates": [[[
          124.8046875,
          63.860035895395306
        ],[
          124.8046875,
          73.860035895395306
        ],
                       [
          128.8046875,
          23.860035895395306
        ]],
                       [[
          24.8046875,
          63.860035895395306
        ],[
          124.8046875,
          73.860035895395306
        ],
                       [
          128.8046875,
          93.860035895395306
        ]]]
      }
    }

单面

{
  "type": "FeatureCollection",
  "features": [
    {
      "type":"Feature",
      "properties":{},
      "geometry":{
        "type":"Polygon",
        "coordinates":[[[66,77],[88,99],[100,100],[66,77]]]
      }
    }
  ]
}

单面中空

重叠区域颜色中空

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          
            [
              [66, 77],
              [88, 99],
              [100, 100],
              [66, 77]
            ],
            [
                [6, 77],
                [88, 99],
                [100, 100],
                [6, 77]
              ]
          
        ]
      }
    }
  ]
}

示例

多面

重叠区域颜色加重

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [66, 77],
              [88, 99],
              [100, 100],
              [66, 77]
            ]
          ],
          [
            [
                [6, 77],
                [88, 99],
                [100, 100],
                [6, 77]
              ]
          ]
        ]
      }
    }
  ]
}

示例