diff options
author | Nicholas Hallahan <nick@theoutpost.io> | 2015-07-14 17:04:13 -0700 |
---|---|---|
committer | Nicholas Hallahan <nick@theoutpost.io> | 2015-07-14 17:04:13 -0700 |
commit | 7c5fde4a3edaf95cc2229453897edf3a3366cd59 (patch) | |
tree | 1a7c87e61d213ce9391987a15ee4066973c6e5d3 | |
parent | afcc78a0aba6a7de6bd676982c9671dbc0eb6acd (diff) | |
download | qtlocation-mapboxgl-7c5fde4a3edaf95cc2229453897edf3a3366cd59.tar.gz |
Fleshed out the shell of the Google Maps API #1716
10 files changed, 563 insertions, 51 deletions
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Annotation.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Annotation.java index fb2b7e2a39..04fa5a4f2c 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Annotation.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Annotation.java @@ -2,30 +2,31 @@ package com.mapbox.mapboxgl.annotations; import com.mapbox.mapboxgl.views.MapView; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ + public abstract class Annotation { /** * The annotation id - * + * <p/> * Internal C++ id is stored as unsigned int. */ - protected Long id; + protected Long id; // null unless added to a MapView private MapView mapView; - public Annotation() {} + float alpha = 1; + boolean visible = true; - public Annotation(long id) { - this.id = id; - } + + public Annotation() {} public long getId() { return id; } + public boolean isVisible() { + return visible; + } + public void remove() { if (mapView == null) return; mapView.removeAnnotation(this); @@ -39,4 +40,8 @@ public abstract class Annotation { this.mapView = mapView; } + public void setVisible(boolean visible) { + this.visible = visible; + } + } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Circle.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Circle.java index 298643f641..6111e959f1 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Circle.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Circle.java @@ -1,8 +1,61 @@ package com.mapbox.mapboxgl.annotations; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ -public class Circle { + +import android.graphics.Color; + +import com.mapbox.mapboxgl.geometry.LatLng; + +public class Circle extends Annotation { + + LatLng center; + int fillColor = Color.BLACK; + double radius; + int strokeColor = Color.BLACK; + float strokeWidth = 10; // Google Maps API defaults to 10 + + public LatLng getCenter() { + return center; + } + + public int getFillColor() { + return fillColor; + } + + /** + * Returns the circle's radius, in meters. + * + * @return radius in meters + */ + public double getRadius() { + return radius; + } + + public int getStrokeColor() { + return strokeColor; + } + + public float getStrokeWidth() { + return strokeWidth; + } + + public void setCenter(LatLng center) { + this.center = center; + } + + public void setFillColor(int color) { + fillColor = color; + } + + public void setRadius(double radius) { + this.radius = radius; + } + + public void setStrokeColor (int color) { + strokeColor = color; + } + + public void setStrokeWidth (float width) { + strokeWidth = width; + } + } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/CircleOptions.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/CircleOptions.java index afb80b78a2..18c570c850 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/CircleOptions.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/CircleOptions.java @@ -1,9 +1,68 @@ package com.mapbox.mapboxgl.annotations; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ + +import com.mapbox.mapboxgl.geometry.LatLng; + public class CircleOptions { + private Circle circle; + + public CircleOptions() { + circle = new Circle(); + } + public CircleOptions center(LatLng center) { + circle.center = center; + return this; + } + + public CircleOptions fillColor(int color) { + circle.fillColor = color; + return this; + } + + public LatLng getCenter() { + return circle.center; + } + + public int getFillColor() { + return circle.fillColor; + } + + public double getRadius() { + return circle.radius; + } + + public int getStrokeColor () { + return circle.strokeColor; + } + + public float getStrokeWidth() { + return circle.strokeWidth; + } + + // TODO: Implement getZIndex of Google Maps Android API +// public float getZIndex () { +// +// } + + public CircleOptions radius (double radius) { + circle.radius = radius; + return this; + } + + public CircleOptions strokeColor(int color) { + circle.strokeColor = color; + return this; + } + + public CircleOptions strokeWidth (float width) { + circle.strokeWidth = width; + return this; + } + + // TODO: Implement zIndex of Google Maps Android API +// public CircleOptions zIndex (float zIndex) { +// +// } + } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java index a178786c51..34413fb979 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Marker.java @@ -2,10 +2,7 @@ package com.mapbox.mapboxgl.annotations; import com.mapbox.mapboxgl.geometry.LatLng; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ + public class Marker extends Annotation { /** @@ -13,7 +10,6 @@ public class Marker extends Annotation { * so that they can be directly set by MarkerOptions * from within the module. */ - float alpha; float anchorU; float anchorV; boolean draggable; @@ -24,13 +20,10 @@ public class Marker extends Annotation { float rotation; String snippet; String title; - boolean visible; private boolean infoWindowShown = false; - public Marker() { - - } + public Marker() {} public boolean equals(Object other) { double lat = position.getLatitude(); @@ -75,7 +68,7 @@ public class Marker extends Annotation { public void hideInfoWindow() { //TODO hideInfoWindow - infoWindowShown = true; + infoWindowShown = false; } public boolean isDraggable() { @@ -90,9 +83,45 @@ public class Marker extends Annotation { return infoWindowShown; } - public boolean isVisible() { - return visible; + void setAlpha(float alpha) { + this.alpha = alpha; + } + + void setDraggable(boolean draggable) { + this.draggable = draggable; + } + + void setFlat(boolean flat) { + this.flat = flat; + } + + // TODO: Implement this method of Google Maps Android API +// void setIcon(BitmapDescriptor icon) { +// +// } + + void setInfoWindowAnchor(float u, float v) { + infoWindowAnchorU = u; + infoWindowAnchorV = v; + } + + void setPosition(LatLng latlng) { + this.position = position; + } + + void setRotation(float rotation) { + this.rotation = rotation; } + void setSnippet(String snippet) { + this.snippet = snippet; + } + + void setTitle(String title) { + this.title = title; + } + void showInfoWindow() { + infoWindowShown = true; + } } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/MultiPoint.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/MultiPoint.java new file mode 100644 index 0000000000..4f01f2c1e6 --- /dev/null +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/MultiPoint.java @@ -0,0 +1,49 @@ +package com.mapbox.mapboxgl.annotations; + +import com.mapbox.mapboxgl.geometry.LatLng; + +import java.util.ArrayList; +import java.util.List; + +public abstract class MultiPoint extends Annotation { + + List<LatLng> points; + + public MultiPoint() { + points = new ArrayList<>(); + } + + public List<LatLng> getPoints() { + return points; + } + + // TODO: Implement getZIndex of Google Maps Android API +// public float getZIndex() { +// +// } + + // TODO: Implement hashCode of Google Maps Android API +// public int hashCode() { +// +// } + + // TODO: Implement isGeodesic of Google Maps Android API +// public boolean isGeodesic() { +// +// } + + /** + * Sets the points of this polyline. This method will take a copy + * of the points, so further mutations to points will have no effect + * on this polyline. + * + * @param points + */ + void setPoints(List<LatLng> points) { + this.points = new ArrayList<>(); + for (LatLng latLng : points) { + this.points.add(latLng); + } + } + +} diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polygon.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polygon.java index acd88673d1..5e4abf680d 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polygon.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polygon.java @@ -1,9 +1,100 @@ package com.mapbox.mapboxgl.annotations; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ -public class Polygon { +import android.graphics.Color; + +import com.mapbox.mapboxgl.geometry.LatLng; + +import java.util.ArrayList; +import java.util.List; + +public class Polygon extends MultiPoint { + + int fillColor = Color.BLACK; // default fillColor is black + float strokeAlpha = 1; + int strokeColor = Color.BLACK; // default strokeColor is black + float strokeWidth = 10; // As specified by Google API Docs (in pixels) + + List<List<LatLng>> holes; + + public Polygon() { + super(); + holes = new ArrayList<>(); + } + + // TODO: Implement equals of Google Maps Android API +// public boolean equals (Object other) { +// +// } + + public int getFillColor() { + return fillColor; + } + + public List<List<LatLng>> getHoles () { + return holes; + } + + public int getStrokeColor() { + return strokeColor; + } + + public float getStrokeWidth() { + return strokeWidth; + } + + // TODO: Implement getZIndex of Google Maps Android API +// public float getZIndex() { +// +// } + + // TODO: Implement hashCode of Google Maps Android API +// public int hashCode () { +// +// } + + public void setFillAlpha(float alpha) { + this.alpha = alpha; + } + + public void setFillColor(int color) { + fillColor = color; + } + + /** + * Sets the holes of this polygon. This method will take a copy of the holes, + * so further mutations to holes will have no effect on this polygon. + * + * @param holes + */ + public void setHoles(List<? extends List<LatLng>> holes) { + this.holes = new ArrayList<>(); + for (List<LatLng> hole : holes) { + List<LatLng> newHole = new ArrayList<>(); + this.holes.add(newHole); + for (LatLng latLng : hole) { + newHole.add(latLng); + } + } + } + + /** + * Sets the alpha (opacity) of the stroke + */ + public void setStrokeAlpha(float alpha) { + strokeAlpha = alpha; + } + + public void setStrokeColor(int color) { + strokeColor = color; + } + + public void setStrokeWidth(float width) { + strokeWidth = width; + } + + // TODO: Implement setZIndex of Google Maps Android API +// public void setZIndex(float zIndex) { +// +// } } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolygonOptions.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolygonOptions.java index 29673465f2..4ffa581677 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolygonOptions.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolygonOptions.java @@ -1,9 +1,91 @@ package com.mapbox.mapboxgl.annotations; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ + +import com.mapbox.mapboxgl.geometry.LatLng; + +import java.util.ArrayList; +import java.util.List; + public class PolygonOptions { + private Polygon polygon; + + public PolygonOptions() { + polygon = new Polygon(); + } + + public PolygonOptions add(LatLng point) { + polygon.points.add(point); + return this; + } + + public PolygonOptions add(LatLng... points) { + for (LatLng point : points) { + add(point); + } + return this; + } + + public PolygonOptions addAll(Iterable<LatLng> points) { + for (LatLng point : points) { + add(point); + } + return this; + } + + public PolygonOptions addHole (Iterable<LatLng> points) { + List<LatLng> hole = new ArrayList<>(); + for (LatLng point : points) { + hole.add(point); + } + polygon.holes.add(hole); + return this; + } + + public PolygonOptions fillColor(int color) { + polygon.fillColor = color; + return this; + } + + public int getFillColor() { + return polygon.fillColor; + } + + public List<List<LatLng>> getHoles() { + return polygon.holes; + } + + public int getStrokeColor() { + return polygon.strokeColor; + } + + public float getStrokeWidth() { + return polygon.strokeWidth; + } + + // TODO: Implement getZIndex of Google Maps Android API +// public float getZIndex() { +// +// } + + public PolygonOptions strokeColor(int color) { + polygon.strokeColor = color; + return this; + } + + public PolygonOptions strokeWidth(float width) { + polygon.strokeWidth = width; + return this; + } + + // TODO: Implement writeToParcel of Google Maps Android API +// public void writeToParcel(Parcel out, int flags) { +// +// } + + // TODO: Implement zIndex of Google Maps Android API +// public PolygonOptions zIndex(float zIndex) { +// +// return this; +// } } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polyline.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polyline.java index c600549788..703e5d5248 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polyline.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/Polyline.java @@ -1,9 +1,62 @@ package com.mapbox.mapboxgl.annotations; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ -public class Polyline { +import android.graphics.Color; + +import com.mapbox.mapboxgl.geometry.LatLng; + +import java.util.List; + +public class Polyline extends MultiPoint { + + int color = Color.BLACK; // default color is black + float width = 10; // As specified by Google API Docs (in pixels) + List<LatLng> points; + + public Polyline() { + super(); + } + + // TODO: Implement equals of Google Maps Android API +// public boolean equals(Object other) { +// +// } + + public int getColor() { + return color; + } + + public float getWidth() { + return width; + } + + + /** + * Sets the color of the polyline. + * + * @param color - the color in ARGB format + */ + public void setColor(int color) { + this.color = color; + } + + // TODO: Implement setGeodesic of Google Maps Android API +// public void setGeodesic(boolean geodesic) { +// +// } + + /** + * Sets the width of the polyline. + * + * @param width in pixels + * @return + */ + public void setWidth(float width) { + this.width = width; + } + + // TODO: Implement setZIndex of Google Maps Android API +// public void setZIndex(float zIndex) { +// +// } } diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolylineOptions.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolylineOptions.java index 4201d41b54..09e7969c38 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolylineOptions.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolylineOptions.java @@ -1,9 +1,102 @@ package com.mapbox.mapboxgl.annotations; -/** - * Created by Nicholas Hallahan on 7/13/15. - * nick@theoutpost.io - */ +import com.mapbox.mapboxgl.geometry.LatLng; + +import java.util.List; + public class PolylineOptions { + private Polyline polyline; + + public PolylineOptions() { + polyline = new Polyline(); + } + + public PolylineOptions alpha(float alpha) { + polyline.alpha = alpha; + return this; + } + + public PolylineOptions add(LatLng point) { + polyline.points.add(point); + return this; + } + + public PolylineOptions add(LatLng... points) { + for (LatLng point : points) { + add(point); + } + return this; + } + + public PolylineOptions addAll(Iterable<LatLng> points) { + for (LatLng point : points) { + add(point); + } + return this; + } + + public PolylineOptions color(int color) { + polyline.color = color; + return this; + } + + // TODO: Implement geodesic of Google Maps Android API +// public PolylineOptions geodesic (boolean geodesic) { +// +// } + + public int getColor() { + return polyline.color; + } + + public List<LatLng> getPoints() { + return polyline.points; + } + + public float getWidth() { + return polyline.width; + } + + // TODO: Implement getZIndex of Google Maps Android API +// public float getZIndex() { +// +// } + + // TODO: Implement isGeodesic of Google Maps Android API +// public boolean isGeodesic() { +// +// } + + public boolean isVisible() { + return polyline.visible; + } + + public PolylineOptions visible(boolean visible) { + polyline.visible = visible; + return this; + } + + /** + * Sets the width of the polyline. + * + * @param width in pixels + * @return + */ + public PolylineOptions width(float width) { + polyline.width = width; + return this; + } + + // TODO: Implement writeToParcel of Google Maps Android API +// public void writeToParcel(Parcel out, int flags) { +// +// } + + // TODO: Implement zIndex of Google Maps Android API +// public PolylineOptions zIndex(float zIndex) { +// +// return this; +// } + } diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java index 9bc696b40c..8f4109fce5 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java @@ -263,8 +263,6 @@ public class MainActivity extends ActionBarActivity { /** * Enable / Disable markers. * - * TODO: Implement updating the UI and removing markers from the map. - * * @param enableMarkers */ private void toggleMarkers(boolean enableMarkers) { |