Merge pull request #9475 from ehermann/add_rotation
Add rotation to setMapLocation API
This commit is contained in:
commit
3945656658
6 changed files with 39 additions and 7 deletions
|
@ -10,12 +10,14 @@ public class SetMapLocationParams extends AidlParams {
|
|||
private double latitude;
|
||||
private double longitude;
|
||||
private int zoom;
|
||||
private float rotation;
|
||||
private boolean animated;
|
||||
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, boolean animated) {
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, float rotation, boolean animated) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.zoom = zoom;
|
||||
this.rotation = rotation;
|
||||
this.animated = animated;
|
||||
}
|
||||
|
||||
|
@ -47,6 +49,10 @@ public class SetMapLocationParams extends AidlParams {
|
|||
return zoom;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public boolean isAnimated() {
|
||||
return animated;
|
||||
}
|
||||
|
@ -56,6 +62,7 @@ public class SetMapLocationParams extends AidlParams {
|
|||
bundle.putDouble("latitude", latitude);
|
||||
bundle.putDouble("longitude", longitude);
|
||||
bundle.putInt("zoom", zoom);
|
||||
bundle.putFloat("rotation", rotation);
|
||||
bundle.putBoolean("animated", animated);
|
||||
}
|
||||
|
||||
|
@ -64,6 +71,7 @@ public class SetMapLocationParams extends AidlParams {
|
|||
latitude = bundle.getDouble("latitude");
|
||||
longitude = bundle.getDouble("longitude");
|
||||
zoom = bundle.getInt("zoom");
|
||||
rotation = bundle.getFloat("rotation");
|
||||
animated = bundle.getBoolean("animated");
|
||||
}
|
||||
}
|
|
@ -8,12 +8,15 @@ public class SetMapLocationParams implements Parcelable {
|
|||
private double latitude;
|
||||
private double longitude;
|
||||
private int zoom;
|
||||
private float rotation;
|
||||
|
||||
private boolean animated;
|
||||
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, boolean animated) {
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, float rotation, boolean animated) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.zoom = zoom;
|
||||
this.rotation = rotation;
|
||||
this.animated = animated;
|
||||
}
|
||||
|
||||
|
@ -44,6 +47,10 @@ public class SetMapLocationParams implements Parcelable {
|
|||
return zoom;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public boolean isAnimated() {
|
||||
return animated;
|
||||
}
|
||||
|
@ -53,6 +60,7 @@ public class SetMapLocationParams implements Parcelable {
|
|||
out.writeDouble(longitude);
|
||||
out.writeInt(zoom);
|
||||
out.writeByte((byte) (animated ? 1 : 0));
|
||||
out.writeFloat(rotation);
|
||||
}
|
||||
|
||||
private void readFromParcel(Parcel in) {
|
||||
|
@ -60,6 +68,7 @@ public class SetMapLocationParams implements Parcelable {
|
|||
longitude = in.readDouble();
|
||||
zoom = in.readInt();
|
||||
animated = in.readByte() != 0;
|
||||
rotation = in.readFloat();
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
|
|
|
@ -138,6 +138,7 @@ public class OsmandAidlApi {
|
|||
private static final String AIDL_LATITUDE = "aidl_latitude";
|
||||
private static final String AIDL_LONGITUDE = "aidl_longitude";
|
||||
private static final String AIDL_ZOOM = "aidl_zoom";
|
||||
private static final String AIDL_ROTATION = "aidl_rotation";
|
||||
private static final String AIDL_ANIMATED = "aidl_animated";
|
||||
|
||||
private static final String AIDL_START_NAME = "aidl_start_name";
|
||||
|
@ -292,6 +293,7 @@ public class OsmandAidlApi {
|
|||
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
|
||||
int zoom = intent.getIntExtra(AIDL_ZOOM, 0);
|
||||
boolean animated = intent.getBooleanExtra(AIDL_ANIMATED, false);
|
||||
float rotation = intent.getFloatExtra(AIDL_ROTATION, Float.NaN);
|
||||
if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
|
||||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
if (zoom == 0) {
|
||||
|
@ -300,6 +302,9 @@ public class OsmandAidlApi {
|
|||
zoom = zoom > mapView.getMaxZoom() ? mapView.getMaxZoom() : zoom;
|
||||
zoom = zoom < mapView.getMinZoom() ? mapView.getMinZoom() : zoom;
|
||||
}
|
||||
if(!Float.isNaN(rotation)) {
|
||||
mapView.setRotate(rotation, false);
|
||||
}
|
||||
if (animated) {
|
||||
mapView.getAnimatedDraggingThread().startMoving(lat, lon, zoom, true);
|
||||
} else {
|
||||
|
@ -1548,12 +1553,13 @@ public class OsmandAidlApi {
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean setMapLocation(double latitude, double longitude, int zoom, boolean animated) {
|
||||
boolean setMapLocation(double latitude, double longitude, int zoom, float rotation, boolean animated) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(AIDL_SET_MAP_LOCATION);
|
||||
intent.putExtra(AIDL_LATITUDE, latitude);
|
||||
intent.putExtra(AIDL_LONGITUDE, longitude);
|
||||
intent.putExtra(AIDL_ZOOM, zoom);
|
||||
intent.putExtra(AIDL_ROTATION, rotation);
|
||||
intent.putExtra(AIDL_ANIMATED, animated);
|
||||
app.sendBroadcast(intent);
|
||||
return true;
|
||||
|
|
|
@ -597,7 +597,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener {
|
|||
if (params != null) {
|
||||
OsmandAidlApi api = getApi("setMapLocation");
|
||||
return api != null && api.setMapLocation(params.getLatitude(), params.getLongitude(),
|
||||
params.getZoom(), params.isAnimated());
|
||||
params.getZoom(), params.getRotation(), params.isAnimated());
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -597,7 +597,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
|||
if (params != null) {
|
||||
OsmandAidlApi api = getApi("setMapLocation");
|
||||
return api != null && api.setMapLocation(params.getLatitude(), params.getLongitude(),
|
||||
params.getZoom(), params.isAnimated());
|
||||
params.getZoom(), params.getRotation(), params.isAnimated());
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -8,12 +8,15 @@ public class SetMapLocationParams implements Parcelable {
|
|||
private double latitude;
|
||||
private double longitude;
|
||||
private int zoom;
|
||||
private float rotation;
|
||||
private boolean animated;
|
||||
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, boolean animated) {
|
||||
|
||||
public SetMapLocationParams(double latitude, double longitude, int zoom, float rotation, boolean animated) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.zoom = zoom;
|
||||
this.rotation = rotation;
|
||||
this.animated = animated;
|
||||
}
|
||||
|
||||
|
@ -44,6 +47,10 @@ public class SetMapLocationParams implements Parcelable {
|
|||
return zoom;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public boolean isAnimated() {
|
||||
return animated;
|
||||
}
|
||||
|
@ -53,6 +60,7 @@ public class SetMapLocationParams implements Parcelable {
|
|||
out.writeDouble(longitude);
|
||||
out.writeInt(zoom);
|
||||
out.writeByte((byte) (animated ? 1 : 0));
|
||||
out.writeFloat(rotation);
|
||||
}
|
||||
|
||||
private void readFromParcel(Parcel in) {
|
||||
|
@ -60,6 +68,7 @@ public class SetMapLocationParams implements Parcelable {
|
|||
longitude = in.readDouble();
|
||||
zoom = in.readInt();
|
||||
animated = in.readByte() != 0;
|
||||
rotation = in.readFloat();
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
|
|
Loading…
Reference in a new issue