将相机对准在Google Maps V2中 [英] centering the camera in Google Maps V2
本文介绍了将相机对准在Google Maps V2中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(Lat ,经度));
DebugLog.debugLog(+ Lat +和+ Lon,false);
CameraUpdate zoom = CameraUpdateFactory.zoomTo(15);
map.moveCamera(center);
map.animateCamera(zoom);
map.addMarker(new MarkerOptions()
.position(new LatLng(Lat,Lon))
.title(Phone Location)
);
Lat为31.7898
Lon为-111.0354
标记正好在正确的位置。然而,相机位于v2地图上该位置以北约5英里处。
为什么?
感谢
加里
解决方案
阅读了一些额外的文档后,我发现下面的代码工作.. 。
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(Lat,Lon))
.zoom(15)
.bearing(0)
.tilt(45)
.build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
map.addMarker(new MarkerOptions()
.position(new LatLng(Lat,Lon))
.title(Phone Location)
);
我认为我的原始代码也应该有效。
加里
In my android app I have the following code...
CameraUpdate center= CameraUpdateFactory.newLatLng(new LatLng(Lat,Lon));
DebugLog.debugLog("centered camera on " + Lat + " and " + Lon, false);
CameraUpdate zoom=CameraUpdateFactory.zoomTo(15);
map.moveCamera(center);
map.animateCamera(zoom);
map.addMarker(new MarkerOptions()
.position(new LatLng(Lat, Lon))
.title("Phone Location")
);
Lat is 31.7898 Lon is -111.0354
The marker is exactly at the proper location. However the camera is centered about 5 miles north of that location on the v2 map. Why? Thanks Gary
解决方案
After reading some additional docs, I found that the following code worked...
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(Lat, Lon))
.zoom(15)
.bearing(0)
.tilt(45)
.build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
map.addMarker(new MarkerOptions()
.position(new LatLng(Lat, Lon))
.title("Phone Location")
);
I think my original code should have also worked. Gary
这篇关于将相机对准在Google Maps V2中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文