【发布时间】:2017-10-16 10:56:39
【问题描述】:
请查看我的代码以从 geojson 字符串创建图层并将图层添加到地图:
private GeoJsonLayer createLayerFromGeojson(String json)
{
JSONObject ob = null;
try
{
ob = new JSONObject(json);
}
catch (JSONException e)
{
e.printStackTrace();
}
GeoJsonLayer layer = new GeoJsonLayer(googleMap, ob);
layer.addLayerToMap();
layer.setOnFeatureClickListener(feature -> Utils.showMessage(getActivity(), "Clicked", feature.getProperty("description").toString()));
return layer;
}
接下来添加 2 个图层到地图:
String json = /*first geojson string here*/
String json2 = /*another geojson string here*/
createLayerFromGeojson(json);
createLayerFromGeojson(json2);
问题:当我点击标记或 pologon 时,总是显示取自第二个 json (json2) 的描述,即使我点击第一层上从第一个 json 创建的对象。
怎么了?有什么想法吗?
【问题讨论】:
标签: android google-maps onclick geojson layer