Android google maps cant zoom with compass active -
hee guys,
i'm using sensorlistener create screen adjust compass. can't zoom in or out because updating photographic camera when onsensorchanged
called. there way create able zoom?
private sensoreventlistener mysensoreventlistener = new sensoreventlistener() { @override public void onaccuracychanged(sensor sensor, int accuracy) { } @override public void onsensorchanged(sensorevent event) { if(routestarted == true) { if(event.sensor.gettype() == sensor.type_rotation_vector) { sensormanager.getrotationmatrixfromvector( mrotationmatrix , event.values); float[] orientation = new float[3]; sensormanager.getorientation(mrotationmatrix, orientation); float bearing = (float) (math.todegrees(orientation[0]) + mdeclination); float tilt = 30; updatecamera(bearing, tilt); } } } }; private void updatecamera(float bearing, float tilt) { // todo auto-generated method stub latlng post = new latlng(mgooglemap.getmylocation().getlatitude(), mgooglemap.getmylocation().getlongitude()); cameraposition pos = new cameraposition(post, 15, tilt, bearing); mgooglemap.movecamera(cameraupdatefactory.newcameraposition(pos)); }
you should utilize currentzoom level obtained map instead of static value 15. this:
float zoom = map.getcameraposition().zoom; cameraposition pos = new cameraposition(post, zoom, tilt, bearing);
if want initialise view on 15, somewhere else illustration when activity starts.
android google-maps zoom
No comments:
Post a Comment