Android谷歌地图v2 moveCamera不起作用 [英] Android google map v2 moveCamera doesn't work
问题描述
我试图像这样控制Google地图相机。
private void setUpMap(){
Log。 e(LOG_TAG,在设置方法中);
mMap.setMyLocationEnabled(true);
LatLng startingPoint = new LatLng(129.13381,129.10372);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(startingPoint,16));
Log.e(LOG_TAG,Setup method+(mMapFragment == null));
LogCat打印
in setup method
in setup method false
显示2个日志意味着 mMap.moveCamera(...)
被称为
setUpMap()
从这里调用
private void setUpMapIfNeeded(){
mMapFragment =(SupportMapFragment)getSupportFragmentManager()。findFragmentByTag MFragment.TAG);
if(mMapFragment!= null){
mMapFragment.getMapAsync(new OnMapReadyCallback(){
@Override
public void onMapReady(GoogleMap googleMap){
mMap = googleMap ;
setUpMap();
}
});
$ / code $ / pre
解决方案在 LatLng startingPoint = new LatLng(129.13381,129.10372);
中指定的坐标似乎有点偏离。更详细地说,最大纬度是90度,这是北极(-90是南极)。
结果将是相机将会请尝试使用已知位置的坐标,例如 LatLng startingPoint = new LatLng(55.70,13.19) ;
这会给你瑞典隆德的地位。
因此,基本上,请修改您的头寸的经纬度坐标。
I'm trying to control Google map camera like this
private void setUpMap() {
Log.e(LOG_TAG, "in setup method");
mMap.setMyLocationEnabled(true);
LatLng startingPoint = new LatLng(129.13381, 129.10372);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(startingPoint, 16));
Log.e(LOG_TAG, "in Setup method" + (mMapFragment == null));
}
LogCat prints
"in setup method"
"in setup method false"
2 log is shown it means mMap.moveCamera(...)
is called
setUpMap()
call from here
private void setUpMapIfNeeded() {
mMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag(MFragment.TAG);
if (mMapFragment != null) {
mMapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
setUpMap();
}
});
}
}
解决方案 Your coordinates specified at LatLng startingPoint = new LatLng(129.13381, 129.10372);
seems to be a bit off. In more detail, the maximum latitude is 90 degrees, which is the north pole (-90 is the south pole).
The result of this will be that the camera will not move to a position which is invalid.
Try using coordinates from a known location, such as LatLng startingPoint = new LatLng(55.70, 13.19);
which will give you the position of Lund, Sweden.
So basically, revise the latitude and longitude coordinates for your position.
这篇关于Android谷歌地图v2 moveCamera不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!