简体   繁体   English

Android Google Maps相机更新,缩放

[英]android google maps camera update,zoom

Hi I have an issue with my Google maps camera and zoom. 嗨,我的Google地图相机和变焦出现问题。 Basically I have a class where I have markers and info windows as well as the map itself. 基本上,我有一堂课,那里有标记和信息窗口以及地图本身。 In another activity I have another class and an option of view on map, but when I click on the view on map option the camera, zoom does not updates & zooms the map on the location that I have set it to. 在另一个活动中,我有另一个班级和一个查看地图的选项,但是当我单击“查看地图”选项的相机时,缩放不会更新并在我设置了该位置的位置上缩放地图。 Any advice guys ? 有什么建议吗? Thanks. 谢谢。

Here is my code where i set the map class to run when the option is selected as well as to update the camera and zoom to the specific location. 这是我的代码,在其中我设置了地图类,以便在选择该选项时运行该地图类,以及更新相机并将其缩放到特定位置。 What I need is to update the camera and zoom to the LOCATION_bar when the option is selected, but what happens is that just the map is opening without zooming or focusing the location_bar. 我需要更新相机,并在选择该选项时将其缩放到LOCATION_bar,但是发生的是,仅在打开地图时没有缩放或聚焦location_bar。

  public class barzoomin extends Activity {
GoogleMap gMap;
private final LatLng LOCATION_bar=new LatLng(x , y);


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Intent intentvbar = new Intent(getApplicationContext(), THEMAP.class);
    startActivity(intentbar);
    gMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
    gMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    CameraUpdate update = CameraUpdateFactory.newLatLngZoom(LOCATION_bar,18);
    gMap.animateCamera(update);

}
    }

Try with another API key. 尝试使用另一个API密钥。 I had the same problem and it solved it! 我有同样的问题,它解决了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM