GeoJson格式详解

{
  "type": "FeatureCollection",
  "features": [
    /*表示地图上一个点*/
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          117.24609374999999,
          36.65079252503471
        ]
      }
    },
    /*表示地图上一条线段*/
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            117.24599450826645,
            36.65120999361623
          ],
          [
            117.24690914154054,
            36.65124657580678
          ],
          [
            117.24694132804869,
            36.65100341150826
          ],
          [
            117.24670529365538,
            36.650695689215624
          ],
          [
            117.24620908498764,
            36.65059024562966
          ]
        ]
      }
    },
    /*表示地图上一个多边形(三角形,正方形,长方形....等等)*/
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              117.15253829956055,
              36.67089730689858
            ],
            [
              117.14584350585938,
              36.658917692387114
            ],
            [
              117.16318130493163,
              36.64721167063527
            ],
            [
              117.17554092407227,
              36.65313376288551
            ],
            [
              117.18034744262694,
              36.66773046368491
            ],
            [
              117.17348098754883,
              36.677643625245274
            ],
            [
              117.15322494506836,
              36.692786266889456
            ],
            [
              117.13193893432617,
              36.68397636535661
            ],
            [
              117.15047836303711,
              36.68012171607383
            ],
            [
              117.15253829956055,
              36.67089730689858
            ]
          ]
        ]
      }
    }
  ]
}

在开发过程中调用一个webAPI的接口,需要传递一个Geojson格式的string字符串:

需求是传递一条线段,期间一直报错无法解析,研究半天,正确格式如下:

"SpatialLocationStr": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"LINESTRING\",\"coordinates\":[[119.92166720920139,29.446581488715278],[119.92151638454861,29.446602918836806],[119.9212109375,29.44662923177083],[119.92076144748263,29.44669677734375],[119.92043023003473,29.446729329427082],[119.92002549913194,29.44680392795139],[119.91955702039931,29.446898328993054],[119.91920844184028,29.446982421875],[119.91896402994792,29.447027452256943],[119.91886962890625,29.44716335720486]]}}]}"

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值