【问题标题】:Invalid GeoJSON object无效的 GeoJSON 对象
【发布时间】:2018-03-25 07:05:50
【问题描述】:

我正在尝试在传单地图中绘制 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. 错误。我的数据结构是否正确?请大家帮帮我。

【问题讨论】:

    标签: leaflet geojson


    【解决方案1】:

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

    GeoJSON 支持以下几何类型:

    PointLineStringPolygonMultiPointMultiLineString和多多边形。

    {
      "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"
          }
        }
      ]
    }
    

    【讨论】:

    • 指向 GeoJSON 规范和可能的一些 linting 工具将非常有用。
    • 当我添加type:Polygon 时出现Invalid GeoJSON object 错误。
    • 检查多边形所需的坐标
    • 是的,检查了 ji..am 在更改结构后得到Invalid LatLng object: (NaN, NaN)
    • "coordinates": [[ [-109.05, 41.00], [-102.06, 40.99], [-102.03, 36.99], [-109.04, 36.99], [-109.05, 41.00] ]]查看此格式或访问leafletjs.com/examples/geojson
    猜你喜欢
    • 1970-01-01
    • 2014-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    相关资源
    最近更新 更多