Fleshed out the shell of the Google Maps API #1716
This commit is contained in:
@@ -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;
|
||||
|
||||
float alpha = 1;
|
||||
boolean visible = true;
|
||||
|
||||
|
||||
public Annotation() {}
|
||||
|
||||
public Annotation(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user