我目前正在分析包含了坐标和HTML代码中JSON对象,并在谷歌地图Android版显示他们......到目前为止,我有这样的方法:Android的谷歌地图HTML标记中的信息窗口
private void createMarkersFromJson(String json) throws JSONException {
// De-serialize the JSON string into an array of objects
JSONArray jsonArray = new JSONArray(json);
for (int i = 0; i < jsonArray.length(); i++) {
// Create a marker for each object in the JSON data.
JSONObject jsonObj = jsonArray.getJSONObject(i);
mMap.addMarker(new MarkerOptions()
.position(new LatLng(
jsonObj.getDouble("lat"),
jsonObj.getDouble("long")
))
);
}
}
参考对于以上代码:https://gist.github.com/TimPim/5902100
此方法成功显示标记。 让我们说我的JSON对象的一部分,我有一个名为“contentString”,其中包含HTML代码的记录。我在想,我怎么会能够在信息窗口中正确显示这个像谷歌显示这里它的JavaScript API:
https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple
我已经看过这个答案,并试图实现它自己,但没有成功: Android Google Maps V2 Title or Snippets Strings From HTML
如果有人能告诉我一个更详细的解决方案,以及它如何应用于这个领域,它将不胜感激。