简体   繁体   中英

android google maps camera update,zoom

Hi I have an issue with my Google maps camera and zoom. 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.

  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. I had the same problem and it solved it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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