Skip to content

Instantly share code, notes, and snippets.

@yushiro
Last active December 18, 2015 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yushiro/5858910 to your computer and use it in GitHub Desktop.
Save yushiro/5858910 to your computer and use it in GitHub Desktop.
Android google map API V2
Programmatically set google map fragment visibility (API2)
private GoogleMap mMap;
private SupportMapFragment mMapFragment;
mMapFragment = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.mapFragment));
mMap = mMapFragment.getMap();
mMapFragment.getView().setVisibility(View.INVISIBLE);
VisibleRegion vr = mMap.getProjection().getVisibleRegion();
double left = vr.latLngBounds.southwest.longitude;
double top = vr.latLngBounds.northeast.latitude;
double right = vr.latLngBounds.northeast.longitude;
double bottom = vr.latLngBounds.southwest.latitude;
地图的隐藏和显示
getSupportFragmentManager().beginTransaction().hide(myMapView).commit();
getSupportFragmentManager().beginTransaction().show(myMapView).commit();
地图的中心点
mMap.getCameraPosition().target
移动地图到某个坐标
mMap.moveCamera(CameraUpdateFactory.newCameraPosition(mMap.getCameraPosition()));
mMap.moveCamera(CameraUpdateFactory.newLatLng(goPoint));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(goPoint, zoomLevel));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment