无效的GeoJSON对象

时间:2018-03-25 07:05:51

标签: leaflet geojson

我正在尝试在传单地图中绘制一个json坐标。这是我的数据

var location={
  "type": "FeatureCollection",
  "features": [
    { "type": "Feature",
      "geometry": {"coordinates": [80.2066734649931, 13.0187039189613]},
      "properties": {
          "assetStatus": "FULL",
          "id": 1747,
          "item": "53 Trailer"
      }
    },
    { "type": "Feature",
      "geometry": {"coordinates": [ 80.2072495864164, 13.0191043036246]},
      "properties": {
          "assetStatus": "EMPTY",
          "id": 1746,
          "item": "53 Trailer"
      }
    },
    { "type": "Feature",
      "geometry": { "coordinates": [ 80.2067574402883, 13.0191983952581]},
      "properties": {
          "assetStatus": "LOADED",
          "id": 1745,
          "item": "53 Trailer"
      }
    }
  ]
}


L.geoJson(location, {
            style : fillAssetColorStyle
        }).addTo(map);

收到Invalid GeoJSON object.错误。我的数据结构是否正确?任何人都可以帮助我们。

1 个答案:

答案 0 :(得分:4)

因为缺少几何类型。 "type": "Point"

GeoJSON支持以下几何类型:

LineString 多边形 MultiPoint MultiLineString 和<强>的MultiPolygon

{
  "type": "FeatureCollection",
  "features": [
    { "type": "Feature",
      "geometry": {"type": "Point","coordinates": [80.2066734649931, 13.0187039189613]},
      "properties": {
          "assetStatus": "FULL",
          "id": 1747,
          "item": "53 Trailer"
      }
    },
    { "type": "Feature",
      "geometry": {"type": "Point","coordinates": [ 80.2072495864164, 13.0191043036246]},
      "properties": {
          "assetStatus": "EMPTY",
          "id": 1746,
          "item": "53 Trailer"
      }
    },
    { "type": "Feature",
      "geometry": { "type": "Point","coordinates": [ 80.2067574402883, 13.0191983952581]},
      "properties": {
          "assetStatus": "LOADED",
          "id": 1745,
          "item": "53 Trailer"
      }
    }
  ]
}
相关问题