2017-05-09 41 views
1

我正在创建类似于此处示例example的webmap,但是使用了我的数据。在html中绘制geojson点

我GeoJSON的点不会显示像的例子,这里的长什么样我GeoJSON的文件points.geojson像:

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

这是我的代码,我已经写了:

<html> 
<head> 
    <title>A Leaflet map!</title> 
    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/> 
    <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> 
    <script src="jquery-2.1.1.min.js"></script> 
    <style> 
     #map{ height: 100% } 
    </style> 
</head> 
<body> 

    <div id="map"></div> 

    <script> 

    // initialize the map 
    var map = L.map('map').setView([42.35, -71.09], 13); 

    // load a tile layer 
    L.tileLayer('http://tiles.mapc.org/basemap/{z}/{x}/{y}.png', 
    { 
     attribution: 'Tiles by <a href="http://mapc.org">MAPC</a>, Data by <a href="http://mass.gov/mgis">MassGIS</a>', 
     maxZoom: 100, 
     minZoom: 9 
    }).addTo(map); 

    // load GeoJSON from an external file 
    $.getJSON("point.geojson",function(data){ 
    // add GeoJSON layer to the map once the file is loaded 
     L.geoJson(data).addTo(map); 
    }); 

    </script> 
</body> 
</html> 

为什么我的观点不显示?

回答

1

我会说,你的观点就出现,但不是你期望他们。

GeoJSON的格式要求的顺序[longitude, latitude]坐标。然后单张内部反转此订单,因为它使用[latitude, longitude]

但你仍然需要养活一个GeoJSON的兼容的数据。

+0

感谢坐标的解释,所以你说的“以GeoJSON符合”数据通过反转坐标或什么意思? –

+0

是的,反转你的坐标。 – ghybs

+0

谢谢!这是问题并通过chrome运行,所以我将浏览器切换到Foxfire并将坐标反转,再次感谢! –