Google 地图 - addGeoJson 不适用于我的文件

Jay*_*iya 6 javascript google-maps geojson

addGeoJson 无法在谷歌地图中为我的文件工作

请检查下面我在 javascript 中使用的代码

//create the map
map = new google.maps.Map(document.getElementById('map-canvas'), {
   zoom: 6,
   center: {lat:49.79, lng: -8.82}
});

// Load GeoJSON.
var promise = $.getJSON("Sensitive_Areas_Nitrates_Rivers.json"); //same as map.data.loadGeoJson();
promise.then(function(data){
    cachedGeoJson = data; //save the geojson in case we want to update its values
    console.log(cachedGeoJson);
    map.data.addGeoJson(cachedGeoJson,{idPropertyName:"id"});  
});
Run Code Online (Sandbox Code Playgroud)

我已经从这里下载了这个文件

你可以查看我的 JSON 文件 Sensitive_Areas_Nitrates_Rivers.json

此外,您可以 使用多边形检查此链接

我使用了以下 JSON 格式,因此您可以检查它

{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "EPSG:27700" } }, "features": [ { "type": "特征", "id": 1, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 500051.6875, 224280.03130000085 ], [ 500047.2812999999, 26492497], 2649249799625 ], [ 499976.6875, 224242.21880000085 ] ] }, "properties": { "OBJECTID": 8, "type_of_sa": "SA_N", "datedesign": 1025136000085" 12、“uwwtd_code”:“UKENRI134”、“shape_Length”:12172.080443901654 } } ] }OBJECTID": 8, "type_of_sa": "SA_N", "datedesign": 1025136000000, "name": "Rivers Itchen", "length_km": 12, "uwwtd_code": "UKENRI134", "shape_Length": 12164430}0}0 }OBJECTID”:8,“type_of_sa”:“SA_N”,“datedesign”:1025136000000,“name”:“Rivers Itchen”,“length_km”:12,“uwwtd_code”:“UKENRI134”,“shape_Length”:12164430}0 }

[500051.6875, 224280.03130000085] - [X, Y] 坐标可能在 EPSG: 27700 到 EPSG:4326 中,现在我们需要在谷歌地图上显示这些坐标,有什么解决办法吗?

Vad*_*hev 1

由于 Google 地图预计 GeoJSON 位于 中EPSG:4326Sensitive_Areas_Nitrates_Rivers.json因此需要重新投影。例如,QGIS可以用于此目的(有关详细信息,请参阅文档)

在此输入图像描述

在此输入图像描述

重新投影的Sensitive_Areas_Nitrates_Rivers.json图层将显示如下:

在此输入图像描述