问题描述
在尝试从附近的地点列表中读取数据并将其设置为在地图上显示时遇到此错误。 您可以从随附的照片中看到错误。 enter image description here
公共类GetNearbyPlaceData扩展了AsyncTask
String googlePlaceData;
GoogleMap mMap;
String url;
@Override
protected String doInBackground(Object... objects) {
mMap = (GoogleMap)objects[0];
url = (String)objects[1];
DownloadUrl downloadUrl = new DownloadUrl();
try {
googlePlaceData = downloadUrl.readUrl(url);
Log.d("url in get nearby",googlePlaceData);
} catch (IOException e) {
e.printstacktrace();
}
return googlePlaceData;
}
@Override
protected void onPostExecute(String s) {
List<HashMap<String,String>> nearbyPlaceList = null;
DataParser parser = new DataParser();
nearbyPlaceList = parser.parse(s);
showNearbyPlaces(nearbyPlaceList);
}
private void showNearbyPlaces(List<HashMap<String,String>> nearbyPlaceList)
{
for (int i = 0; i<nearbyPlaceList.size();i++)
{
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String,String > googlePlace = nearbyPlaceList.get(i);
String placeName = googlePlace.get("place_name");
Log.d("placeName",placeName);
String vicinity = googlePlace.get("vicinity");
double lat = Double.parseDouble( googlePlace.get("lat"));
double lng = Double.parseDouble( googlePlace.get("lng"));
Log.d("lat",Double.toString(lat));
Log.d("lat",Double.toString(lng));
LatLng latLng = new LatLng(lat,lng);
markerOptions.position(latLng);
markerOptions.title(placeName+":"+vicinity);
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(10));
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)