在html中绘制geojson点

时间:2017-05-09 20:01:37

标签: javascript html leaflet geojson

我正在创建一个类似于example示例的网络地图,但是我的数据。

我的geojson点不会像示例那样显示,这是我的geojson文件 points.geojson 的样子:

@Inject

这是我写的代码:

    {
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "RENTAL_ID": 146057249, "CUSTOMER_I": 2256099, "LOCATION": "Boston", "VEHICLE_VI": "FHB 1675", "START_DATE": "2017\/03\/1 00:03:00", "END_DATE_L": "2017\/03\/1 00:10:00", "END_LATITU": 30.22478, "END_LONGIT": -97.72464, "DISTANCE": 5, "DURATION": 7, "DURATION_P": 0, "DURATION_D": 7, "SERVICE_DR": 0, "VEHICLE_TY": "HW 2.0" }, "geometry": { "type": "Point", "coordinates": [ 42.355672, -71.058712 ] } },
{ "type": "Feature", "properties": { "RENTAL_ID": 146057187, "CUSTOMER_I": 2435897, "LOCATION": "Boston", "VEHICLE_VI": "JHD 8492", "START_DATE": "2017\/03\/1 00:00:00", "END_DATE_L": "2017\/03\/1 00:19:00", "END_LATITU": 30.25766855, "END_LONGIT": -97.7383573, "DISTANCE": 13, "DURATION": 19, "DURATION_P": 0, "DURATION_D": 19, "SERVICE_DR": 0, "VEHICLE_TY": "B Class" }, "geometry": { "type": "Point", "coordinates": [ 42.361507, -71.090126 ] } }
]
}

为什么我的分数没有显示?

1 个答案:

答案 0 :(得分:1)

我会说你的观点确实出现了,但不是你期望的那样。

GeoJSON格式需要[longitude, latitude]的坐标。 Leaflet然后在内部反转此顺序,因为它使用[latitude, longitude]

但您仍然需要提供符合GeoJSON标准的数据。