【发布时间】:2015-02-05 07:15:58
【问题描述】:
我正在开发一个应用程序,它需要将用户的当前位置标记到谷歌地图上。我已经有了在当前位置设置标记的代码。
private void handleNewLocation(Location location) {
Log.d(TAG, location.toString());
//get the new latitude and longitude
double currentLatitude = location.getLatitude();
double currentLongitude = location.getLongitude();
//create object to store them
LatLng latLng = new LatLng(currentLatitude, currentLongitude);
//create marker with the new position
MarkerOptions options = new MarkerOptions()
.position(latLng)
.title("I am here!");
//add marker to the map
mMap.addMarker(options);
//move camera to current location
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
}
编译时没有显示错误。但是在模拟器上运行时,它显示“MapActivity 已停止工作”。
我正在使用 Nexus 5 API 21x86 android 虚拟设备来运行应用程序。
请帮忙!!!!!!!
【问题讨论】:
-
请发布您的 Logcat 。要查找您的 Logcat,请参考here
-
请检查下面发布的答案并指导我。非常感谢!
标签: google-maps android-studio