在 Android 错误中添加一个 geojson 文件(用 try/catch 包围)
Add a geojson file in Android error (Surround with try/catch)
我尝试将 geojson 导入我的 Google 地图 Android 应用程序。但是我在代码中有以下错误。
The Code for adding geojson:
GeoJsonLayer layer = new GeoJsonLayer(mMap, R.raw.nbg_bank ,
getApplicationContext());
layer.addLayerToMap();
and the error:unreported exception IOException; must be caught or declared to be thrown
是做try/catch的解决方案吗?
当我执行 try/catch 时,代码更改为没有任何错误,但我在地图应用程序中看不到点:
GeoJsonLayer layer = null;
try {
layer = new GeoJsonLayer(mMap, R.raw.nbg_bank ,
getApplicationContext());
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
layer.addLayerToMap();
答案是:try/catch解决就可以了。问题是坐标系。我使用 WGS84,但 EPSG:4326 是正确的,而不是我使用的 epsg:3857 crs。
我尝试将 geojson 导入我的 Google 地图 Android 应用程序。但是我在代码中有以下错误。
The Code for adding geojson:
GeoJsonLayer layer = new GeoJsonLayer(mMap, R.raw.nbg_bank ,
getApplicationContext());
layer.addLayerToMap();
and the error:unreported exception IOException; must be caught or declared to be thrown
是做try/catch的解决方案吗?
当我执行 try/catch 时,代码更改为没有任何错误,但我在地图应用程序中看不到点:
GeoJsonLayer layer = null;
try {
layer = new GeoJsonLayer(mMap, R.raw.nbg_bank ,
getApplicationContext());
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
layer.addLayerToMap();
答案是:try/catch解决就可以了。问题是坐标系。我使用 WGS84,但 EPSG:4326 是正确的,而不是我使用的 epsg:3857 crs。