2017-05-09 3 views
1

私はここの例のようなWebマップを作成しますが、私のデータはexampleです。htmlの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> 

私にGeoJSONポイントはここに私にGeoJSONファイルpoints.geojsonは次のようになります、例のように表示されませんポイントが表示されないのはなぜですか?

答えて

1

あなたのポイントは表示されますが、予想される場所は表示されません。

GeoJSONフォーマットでは、座標が[longitude, latitude]であると想定しています。リーフレットは[latitude, longitude]を使用しているため、内部でこの順序を逆転します。

しかし、GeoJSON準拠のデータをフィードする必要があります。

+0

座標説明のおかげで、座標を逆にして "GeoJSON準拠"データを意味するのでしょうか? –

+0

はい、座標を逆転します。 – ghybs

+0

感謝します!それは問題だったし、クロムを介して実行するので、私は再びFoxfireと座標を逆にブラウザを切り替え、ありがとう! –

関連する問題