Commit c0cd37b2 authored by ChitiSims's avatar ChitiSims Committed by Evan W. Patton

Add Rotation property

Users could rotate the map but not programmatically. This change adds
blocks to allow developers to programmatically change the map rotation.

Fixes #1082

Change-Id: I476263bb834cf32f4ab8c74c3f525ab0224362d8
parent 408f3ed1
......@@ -7019,4 +7019,8 @@ public interface OdeMessages extends Messages {
@DefaultMessage("SetCenter")
@Description("")
String SetCenterMethods();
@DefaultMessage("Rotation")
@Description("")
String RotationProperties();
}
......@@ -1525,12 +1525,14 @@ public final class YoungAndroidFormUpgrader {
private static int upgradeMapProperties(Map<String, JSONValue> componentProperties,
int srcCompVersion) {
if (srcCompVersion < 3) {
if (srcCompVersion < 4) {
// Version 2
// The Markers property (blocks-only) was renamed to Features
// Version 3
// Block event handlers were renamed
srcCompVersion = 3;
// Version 4
// The Rotation property was added with default 0.0 (due north)
srcCompVersion = 4;
}
return srcCompVersion;
}
......
......@@ -1848,7 +1848,11 @@ Blockly.Versioning.AllUpgradeMaps =
3: [
Blockly.Versioning.changeEventName('Map', 'GotGeoJSON', 'GotFeatures'),
Blockly.Versioning.changeEventName('Map', 'GeoJSONError', 'LoadError')
]
],
// AI2:
// - The Rotation property was added to Map
4: "noUpgrade"
}, // End Map upgraders
......
......@@ -425,8 +425,10 @@ public class YaVersion {
// - BLOCKS_LANGUAGE_VERSION was incremented to 22
// For YOUNG_ANDROID_VERSION 169:
// - NOTIFIER_COMPONENT_VERSION was incremented to 5
// For YOUNG_ANDROID_VERSION 170:
// - MAP_COMPONENT_VERSION was incremented to 4
public static final int YOUNG_ANDROID_VERSION = 169;
public static final int YOUNG_ANDROID_VERSION = 170;
// ............................... Blocks Language Version Number ...............................
......@@ -856,7 +858,9 @@ public class YaVersion {
// For MAP_COMPONENT_VERSION 3:
// - GotGeoJSON was renamed to GotFeatures
// - GeoJSONError was renamed to LoadError
public static final int MAP_COMPONENT_VERSION = 3;
// For MAP_COMPONENT_VERSION 4:
// - Added Rotation property
public static final int MAP_COMPONENT_VERSION = 4;
// For MARKER_COMPONENT_VERSION 1:
// - Initial Marker implementation using OpenStreetMap
......
......@@ -260,6 +260,17 @@ public class Map extends MapFeatureContainerBase implements MapEventListener {
return mapController.isZoomEnabled();
}
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_FLOAT, defaultValue = "0.0")
@SimpleProperty
public void Rotation(float rotation) {
mapController.setRotation(rotation);
}
@SimpleProperty (category = PropertyCategory.APPEARANCE, description = "Sets or gets the rotation of the map in decimal degrees if any")
public float Rotation() {
return mapController.getRotation();
}
/**
* <p>Set the type of map tile used for the base tile layer. Valid values are:</p>
* <ol>
......
......@@ -44,6 +44,14 @@ class DummyMapController implements MapController {
throw new UnsupportedOperationException();
}
public void setRotation(float Rotation) {
throw new UnsupportedOperationException();
}
public float getRotation() {
throw new UnsupportedOperationException();
}
public int getZoom() {
throw new UnsupportedOperationException();
}
......
......@@ -512,6 +512,18 @@ public final class MapFactory {
* @return the number of overlays on the map
*/
int getOverlayCount();
/**
* Sets the rotation of the map in degrees
* @param Rotation in degrees
*/
void setRotation(float Rotation);
/**
* Gets the rotation of the map in degrees
* @return the rotation
*/
float getRotation();
}
/**
......
......@@ -1168,6 +1168,16 @@ class NativeOpenStreetMapController implements MapController, MapListener {
return view.getOverlays().size();
}
@Override
public void setRotation(float Rotation) {
view.setMapOrientation(Rotation);
}
@Override
public float getRotation() {
return view.getMapOrientation();
}
static class MultiPolygon extends Polygon {
private List<Polygon> children = new ArrayList<Polygon>();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment