【发布时间】:2018-03-27 02:02:18
【问题描述】:
我有一个非常奇怪的问题,我无法在任何地方找到答案。
目标:
当我将模型加载到地图上时,我会从该模型中提取一个点,该点就是我想要设置为新相机中心的点。
问题:
当我使用map.animateCamera(position) 时,相机会移动到模型下方。我无法推断出什么是错误的,我已经搜索了文档但没有找到任何东西。
我是如何测试的:
为了测试位置是否正确,我在该点所在的地图上放置了一个标记,并且该标记位于正确的位置,这意味着相机是问题所在。
我也尝试过不同的方法map.moveCamera() 以及CameraUpdateFactory.newCameraPosition() 等...
代码
private void recenterModel(List<PolygonOptions> t) {
if(t == null || t.isEmpty()) return;
int center = t.size()/2;
PolygonOptions polygon = t.get(center);
while(polygon.getPoints().isEmpty()){
polygon = t.get((++center%t.size()));
if(center > t.size()+1) return; /*If we are here, there aren't any points in model*/
}
center = polygon.getPoints().size()/2;
LatLng centerPoint = polygon.getPoints().get(center);
GoogleMap map = modelMapDrawable.ctx.getMap();
map.animateCamera(CameraUpdateFactory.newLatLngZoom(centerPoint , 15));
map.addMarker(new MarkerOptions().position(centerPoint));
}
在我看来是什么
当我第一次加载应用程序时,它会正确加载项目的中心点。 map.animateCamera() 就像一个魅力。每次我为中心点做这件事时,它都会起作用。 但是当我对其他位置执行map.animateCamera() 时,我无法让它再次工作。
所以在我看来,相机的坐标系被移动了
【问题讨论】:
-
你有没有找到解决办法。在我的情况下,它就像将提供的经纬度移动到屏幕的左上角。不知道如何处理。
标签: android google-maps