Home > other >  Android - when we rotate the phone, how to rotate arrows in forward v2 Google
Android - when we rotate the phone, how to rotate arrows in forward v2 Google

Time:03-19

Anyone can help me to solve how to rotate arrows in the Google maps v2? You have seen, in a navigation arrow towards the direction we face. I want it to happen to my application. Concerning markerOption. Rotation (rotation), I think it seems to be a static. I want to on the phone when the dynamic rotate arrows.

CodePudding user response:

I can do that. It's so easy. Here's how to. This is read sensor and obtain the direction of the mobile phone.

/* *
* Initialize the sensor manager.
*/
Private void setupSensorManager () {
MSensorManager=(SensorManager) mContext
GetSystemService (Context. SENSOR_SERVICE);
MSensorManager. RegisterListener (mSensorListener,
MSensorManager. GetDefaultSensor (Sensor. TYPE_ORIENTATION),
SensorManager. SENSOR_DELAY_NORMAL);

The d (TAG, "SensorManager setup");
}

/* *
* The sensor event listener.
*/
SensorEventListener mSensorListener=new SensorEventListener () {

@ Override
Public void onSensorChanged (SensorEvent event) {
MOrientation=event. Values [0];
The d (TAG, "Phone version" + mOrientation);
The draw (mOrientation);
}

@ Override
Public void onAccuracyChanged (Sensor, Sensor, int accuracy) {
}
};

This is the place where I really spin. I tag has been added to the map. I visit it from another class.

Public void the draw (float Angle) {
//Take the relevant Marker from the Marker list where the available in the map
AndroidMapGoogleOverlayItem myself=(AndroidMapGoogleOverlayItem) getOverlayItem (0);

If (myself==null) {
return;
}
Myself. GetMarker (.) setRotation (mOrientation);//set the orientation value returned from the senserManager
}

CodePudding user response:


Great god!!!!!
What is AndroidMapGoogleOverlayItem

CodePudding user response:

Me how I can show the location of the direction of the arrow, and Google map according to the equipment in the direction of rotation,!!!!!!!!!!

CodePudding user response:

Ever bosses, with solving!!!!!! Thank you five body and kneel!!!!! Online urgent!!!!!!
  • Related