Code example for GoogleMap

Methods: addMarker, animateCamera, getCameraPosition, getProjection

0
			@Override 
			public void onLocationChanged(Location location) {
				// TODO Auto-generated method stub 
				if(pos != null)
					pos.remove();
				pos = map.addMarker(new MarkerOptions().position(new LatLng(location.getLatitude(), location.getLongitude())).title("Your current coordinates are: " + (int)location.getLatitude() + "," + (int)location.getLongitude()));
				//map.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude()))); 
				//map.animateCamera(CameraUpdateFactory.zoomTo(map.getCameraPosition().zoom), 2000, null);	 
				 
				//LatLng mapBounds = map.getCameraPosition().target; 
				bounds = map.getProjection().getVisibleRegion().latLngBounds;
				System.out.println(bounds.northeast.latitude + "," + bounds.southwest.latitude);
				if(bounds.northeast.longitude > NORTH_LIMIT || bounds.southwest.longitude < SOUTH_LIMIT || bounds.southwest.latitude < WEST_LIMIT || bounds.northeast.latitude > EAST_LIMIT) {
					if(map.getCameraPosition().zoom >= 15)
						camPos = new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude())).zoom(map.getCameraPosition().zoom).bearing(75).build();
					else 
						camPos = new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude())).zoom(15).bearing(75).build();
					map.animateCamera(CameraUpdateFactory.newCameraPosition(camPos));
				} 
 
			} 
 
			@Override