[android] Tidy up annotations API
Make unimplemented properties package private. Make annotations object properties immutable. Make InfoWindow and Circle classes package private. Remove no longer needed casts from Options classes. Added a few missing get/add methods to annotations classes for consistency. Mininal version of #2546 suitable for v2.1.0 release.
This commit is contained in:
@@ -9,23 +9,26 @@ public abstract class Annotation implements Comparable<Annotation> {
|
||||
*
|
||||
* Internal C++ id is stored as unsigned int.
|
||||
*/
|
||||
protected long id = -1; // -1 unless added to a MapView
|
||||
protected MapView mapView;
|
||||
private long id = -1; // -1 unless added to a MapView
|
||||
private MapView mapView;
|
||||
|
||||
float alpha = 1.0f;
|
||||
boolean visible = true;
|
||||
private float alpha = 1.0f;
|
||||
private boolean visible = true;
|
||||
|
||||
public Annotation() {}
|
||||
protected Annotation() {}
|
||||
|
||||
public float getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
@@ -34,19 +37,29 @@ public abstract class Annotation implements Comparable<Annotation> {
|
||||
mapView.removeAnnotation(this);
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha) {
|
||||
void setAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public void setMapView(MapView mapView) {
|
||||
this.mapView = mapView;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
protected MapView getMapView() {
|
||||
return mapView;
|
||||
}
|
||||
|
||||
void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1882
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1726
|
||||
*/
|
||||
public class Circle extends Annotation {
|
||||
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
|
||||
private LatLng center;
|
||||
private int fillColor = Color.BLACK;
|
||||
private double radius;
|
||||
private int strokeColor = Color.BLACK;
|
||||
private float strokeWidth = 10; // Google Maps API defaults to 10
|
||||
|
||||
public LatLng getCenter() {
|
||||
return center;
|
||||
@@ -44,23 +44,23 @@ public class Circle extends Annotation {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
public void setCenter(LatLng center) {
|
||||
void setCenter(LatLng center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
public void setFillColor(int color) {
|
||||
void setFillColor(int color) {
|
||||
fillColor = color;
|
||||
}
|
||||
|
||||
public void setRadius(double radius) {
|
||||
void setRadius(double radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public void setStrokeColor (int color) {
|
||||
void setStrokeColor (int color) {
|
||||
strokeColor = color;
|
||||
}
|
||||
|
||||
public void setStrokeWidth (float width) {
|
||||
void setStrokeWidth (float width) {
|
||||
strokeWidth = width;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1882
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1726
|
||||
*/
|
||||
public class CircleOptions {
|
||||
class CircleOptions {
|
||||
|
||||
private Circle circle;
|
||||
|
||||
@@ -17,60 +17,65 @@ public class CircleOptions {
|
||||
circle = new Circle();
|
||||
}
|
||||
public CircleOptions center(LatLng center) {
|
||||
circle.center = center;
|
||||
circle.setCenter(center);;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CircleOptions fillColor(int color) {
|
||||
circle.fillColor = color;
|
||||
circle.setFillColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LatLng getCenter() {
|
||||
return circle.center;
|
||||
return circle.getCenter();
|
||||
}
|
||||
|
||||
public int getFillColor() {
|
||||
return circle.fillColor;
|
||||
return circle.getFillColor();
|
||||
}
|
||||
|
||||
public double getRadius() {
|
||||
return circle.radius;
|
||||
return circle.getRadius();
|
||||
}
|
||||
|
||||
public int getStrokeColor () {
|
||||
return circle.strokeColor;
|
||||
return circle.getStrokeColor();
|
||||
}
|
||||
|
||||
public float getStrokeWidth() {
|
||||
return circle.strokeWidth;
|
||||
return circle.getStrokeWidth();
|
||||
}
|
||||
|
||||
public CircleOptions radius (double radius) {
|
||||
circle.radius = radius;
|
||||
public CircleOptions radius(double radius) {
|
||||
circle.setRadius(radius);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CircleOptions strokeColor(int color) {
|
||||
circle.strokeColor = color;
|
||||
circle.setStrokeColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CircleOptions strokeWidth (float width) {
|
||||
circle.strokeWidth = width;
|
||||
circle.setStrokeWidth(width);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CircleOptions alpha(float alpha) {
|
||||
circle.alpha = alpha;
|
||||
circle.setAlpha(alpha);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return circle.alpha;
|
||||
return circle.getAlpha();
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return circle.visible;
|
||||
private CircleOptions visible(boolean visible) {
|
||||
circle.setVisible(visible);
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean isVisible() {
|
||||
return circle.isVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.mapbox.mapboxsdk.views.MapView;
|
||||
/**
|
||||
* A tooltip view
|
||||
*/
|
||||
public final class InfoWindow {
|
||||
final class InfoWindow {
|
||||
|
||||
private Marker boundMarker;
|
||||
private MapView mMapView;
|
||||
|
||||
@@ -8,7 +8,7 @@ import android.graphics.Path;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public final class InfoWindowTipView extends View {
|
||||
final class InfoWindowTipView extends View {
|
||||
|
||||
private Paint mPaint;
|
||||
private Path mPath;
|
||||
|
||||
@@ -7,7 +7,7 @@ import android.widget.RelativeLayout;
|
||||
|
||||
import com.mapbox.mapboxsdk.R;
|
||||
|
||||
public class InfoWindowView extends RelativeLayout{
|
||||
class InfoWindowView extends RelativeLayout{
|
||||
|
||||
private InfoWindowTipView mTipView;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import android.view.View;
|
||||
import com.mapbox.mapboxsdk.R;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
public class Marker extends Annotation {
|
||||
public final class Marker extends Annotation {
|
||||
|
||||
private float anchorU;
|
||||
private float anchorV;
|
||||
@@ -28,7 +28,7 @@ public class Marker extends Annotation {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Marker() {
|
||||
Marker() {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -48,10 +48,6 @@ public class Marker extends Annotation {
|
||||
return (lat == otherLat && otherLng == lng);
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public Point getAnchor() {
|
||||
return new Point((int)anchorU, (int)anchorV);
|
||||
}
|
||||
@@ -64,11 +60,11 @@ public class Marker extends Annotation {
|
||||
return anchorV;
|
||||
}
|
||||
|
||||
public float getInfoWindowAnchorU() {
|
||||
float getInfoWindowAnchorU() {
|
||||
return infoWindowAnchorU;
|
||||
}
|
||||
|
||||
public float getInfoWindowAnchorV() {
|
||||
float getInfoWindowAnchorV() {
|
||||
return infoWindowAnchorV;
|
||||
}
|
||||
|
||||
@@ -76,7 +72,7 @@ public class Marker extends Annotation {
|
||||
return position;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
float getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@@ -88,6 +84,9 @@ public class Marker extends Annotation {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public void hideInfoWindow() {
|
||||
if (infoWindow != null) {
|
||||
infoWindow.close();
|
||||
@@ -95,45 +94,48 @@ public class Marker extends Annotation {
|
||||
infoWindowShown = false;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
boolean isDraggable() {
|
||||
return draggable;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
boolean isFlat() {
|
||||
return flat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public boolean isInfoWindowShown () {
|
||||
return infoWindowShown;
|
||||
}
|
||||
|
||||
public void setAnchor(float u, float v) {
|
||||
void setAnchor(float u, float v) {
|
||||
this.anchorU = u;
|
||||
this.anchorV = v;
|
||||
}
|
||||
|
||||
public void setDraggable(boolean draggable) {
|
||||
void setDraggable(boolean draggable) {
|
||||
this.draggable = draggable;
|
||||
}
|
||||
|
||||
public void setFlat(boolean flat) {
|
||||
void setFlat(boolean flat) {
|
||||
this.flat = flat;
|
||||
}
|
||||
|
||||
public void setInfoWindowAnchor(float u, float v) {
|
||||
void setInfoWindowAnchor(float u, float v) {
|
||||
infoWindowAnchorU = u;
|
||||
infoWindowAnchorV = v;
|
||||
}
|
||||
|
||||
public void setPosition(LatLng position) {
|
||||
void setPosition(LatLng position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void setRotation(float rotation) {
|
||||
void setRotation(float rotation) {
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
public void setSnippet(String snippet) {
|
||||
void setSnippet(String snippet) {
|
||||
this.snippet = snippet;
|
||||
}
|
||||
|
||||
@@ -147,7 +149,7 @@ public class Marker extends Annotation {
|
||||
*
|
||||
* @param sprite The name of the sprite.
|
||||
*/
|
||||
public void setSprite(@Nullable String sprite) {
|
||||
void setSprite(@Nullable String sprite) {
|
||||
if (!TextUtils.isEmpty(sprite)) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
@@ -157,12 +159,15 @@ public class Marker extends Annotation {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public void showInfoWindow() {
|
||||
if (!isVisible() || mapView == null) {
|
||||
if (!isVisible() || getMapView() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -170,12 +175,15 @@ public class Marker extends Annotation {
|
||||
showInfoWindow(getInfoWindow());
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public void showInfoWindow(View view){
|
||||
if (!isVisible() || mapView == null) {
|
||||
if (!isVisible() || getMapView() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
infoWindow = new InfoWindow(view, mapView);
|
||||
infoWindow = new InfoWindow(view, getMapView());
|
||||
showInfoWindow(infoWindow);
|
||||
}
|
||||
|
||||
@@ -203,13 +211,13 @@ public class Marker extends Annotation {
|
||||
*/
|
||||
private InfoWindow getInfoWindow() {
|
||||
if (infoWindow == null) {
|
||||
infoWindow = new InfoWindow(R.layout.infowindow_view, mapView);
|
||||
infoWindow = new InfoWindow(R.layout.infowindow_view, getMapView());
|
||||
}
|
||||
return infoWindow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
if (!visible && infoWindowShown) {
|
||||
hideInfoWindow();
|
||||
@@ -224,10 +232,16 @@ public class Marker extends Annotation {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public int getTopOffsetPixels() {
|
||||
return topOffsetPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public void setTopOffsetPixels(int topOffsetPixels) {
|
||||
this.topOffsetPixels = topOffsetPixels;
|
||||
}
|
||||
|
||||
@@ -4,35 +4,35 @@ import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
public class MarkerOptions {
|
||||
public final class MarkerOptions {
|
||||
|
||||
protected Annotation annotation;
|
||||
private Marker marker;
|
||||
|
||||
public MarkerOptions() {
|
||||
annotation = new Marker();
|
||||
marker = new Marker();
|
||||
}
|
||||
|
||||
public MarkerOptions anchor(float u, float v) {
|
||||
((Marker)annotation).setAnchor(u, v);
|
||||
marker.setAnchor(u, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions draggable(boolean draggable) {
|
||||
((Marker)annotation).setDraggable(draggable);
|
||||
private MarkerOptions draggable(boolean draggable) {
|
||||
marker.setDraggable(draggable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions flat(boolean flat) {
|
||||
((Marker)annotation).setFlat(flat);
|
||||
private MarkerOptions flat(boolean flat) {
|
||||
marker.setFlat(flat);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAnchorU() {
|
||||
return ((Marker)annotation).getAnchorU();
|
||||
return marker.getAnchorU();
|
||||
}
|
||||
|
||||
public float getAnchorV() {
|
||||
return ((Marker)annotation).getAnchorV();
|
||||
return marker.getAnchorV();
|
||||
}
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
@@ -40,94 +40,97 @@ public class MarkerOptions {
|
||||
//
|
||||
// }
|
||||
|
||||
public float getInfoWindowAnchorU() {
|
||||
return ((Marker)annotation).getInfoWindowAnchorU();
|
||||
private float getInfoWindowAnchorU() {
|
||||
return marker.getInfoWindowAnchorU();
|
||||
}
|
||||
|
||||
public float getInfoWindowAnchorV() {
|
||||
return ((Marker)annotation).getInfoWindowAnchorV();
|
||||
private float getInfoWindowAnchorV() {
|
||||
return marker.getInfoWindowAnchorV();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public Marker getMarker() {
|
||||
return (Marker)annotation;
|
||||
return (Marker) marker;
|
||||
}
|
||||
|
||||
public LatLng getPosition() {
|
||||
return ((Marker)annotation).getPosition();
|
||||
return marker.getPosition();
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return ((Marker)annotation).getRotation();
|
||||
private float getRotation() {
|
||||
return marker.getRotation();
|
||||
}
|
||||
|
||||
public String getSnippet() {
|
||||
return ((Marker)annotation).getSnippet();
|
||||
return marker.getSnippet();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return ((Marker)annotation).getTitle();
|
||||
return marker.getTitle();
|
||||
}
|
||||
|
||||
public String getSprite() {
|
||||
return ((Marker)annotation).getSprite();
|
||||
return marker.getSprite();
|
||||
}
|
||||
|
||||
public MarkerOptions infoWindowAnchor(float u, float v) {
|
||||
((Marker)annotation).setInfoWindowAnchor(u, v);
|
||||
private MarkerOptions infoWindowAnchor(float u, float v) {
|
||||
marker.setInfoWindowAnchor(u, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return ((Marker)annotation).isDraggable();
|
||||
private boolean isDraggable() {
|
||||
return marker.isDraggable();
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return ((Marker)annotation).isFlat();
|
||||
private boolean isFlat() {
|
||||
return marker.isFlat();
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return ((Marker)annotation).isVisible();
|
||||
private boolean isVisible() {
|
||||
return marker.isVisible();
|
||||
}
|
||||
|
||||
public MarkerOptions position(LatLng position) {
|
||||
((Marker)annotation).setPosition(position);
|
||||
marker.setPosition(position);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions rotation(float rotation) {
|
||||
((Marker)annotation).setRotation(rotation);
|
||||
private MarkerOptions rotation(float rotation) {
|
||||
marker.setRotation(rotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions snippet(String snippet) {
|
||||
((Marker)annotation).setSnippet(snippet);
|
||||
marker.setSnippet(snippet);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions sprite(@Nullable String sprite) {
|
||||
if (!TextUtils.isEmpty(sprite)) {
|
||||
((Marker)annotation).setSprite(sprite);
|
||||
marker.setSprite(sprite);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions title(String title) {
|
||||
((Marker)annotation).setTitle(title);
|
||||
marker.setTitle(title);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions visible(boolean visible) {
|
||||
annotation.setVisible(visible);
|
||||
private MarkerOptions visible(boolean visible) {
|
||||
marker.setVisible(visible);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions alpha(float alpha) {
|
||||
annotation.setAlpha(alpha);
|
||||
private MarkerOptions alpha(float alpha) {
|
||||
marker.setAlpha(alpha);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return annotation.alpha;
|
||||
private float getAlpha() {
|
||||
return marker.getAlpha();
|
||||
}
|
||||
|
||||
// TODO: Implement this method of Google Maps Android API
|
||||
|
||||
@@ -7,9 +7,9 @@ import java.util.List;
|
||||
|
||||
public abstract class MultiPoint extends Annotation {
|
||||
|
||||
List<LatLng> points;
|
||||
private List<LatLng> points;
|
||||
|
||||
public MultiPoint() {
|
||||
protected MultiPoint() {
|
||||
super();
|
||||
points = new ArrayList<>();
|
||||
}
|
||||
@@ -34,6 +34,10 @@ public abstract class MultiPoint extends Annotation {
|
||||
this.points = new ArrayList<>(points);
|
||||
}
|
||||
|
||||
void addPoint(LatLng point) {
|
||||
points.add(point);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement hashCode of Google Maps Android API
|
||||
// public int hashCode() {
|
||||
|
||||
@@ -8,16 +8,16 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Polygon extends MultiPoint {
|
||||
public final 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)
|
||||
private int fillColor = Color.BLACK; // default fillColor is black
|
||||
private float strokeAlpha = 1;
|
||||
private int strokeColor = Color.BLACK; // default strokeColor is black
|
||||
private float strokeWidth = 10; // As specified by Google API Docs (in pixels)
|
||||
|
||||
List<List<LatLng>> holes;
|
||||
private List<List<LatLng>> holes;
|
||||
|
||||
public Polygon() {
|
||||
Polygon() {
|
||||
super();
|
||||
holes = new ArrayList<>();
|
||||
}
|
||||
@@ -26,8 +26,8 @@ public class Polygon extends MultiPoint {
|
||||
return fillColor;
|
||||
}
|
||||
|
||||
public List<List<LatLng>> getHoles () {
|
||||
return holes;
|
||||
List<List<LatLng>> getHoles () {
|
||||
return new ArrayList<>(holes);
|
||||
}
|
||||
|
||||
public int getStrokeColor() {
|
||||
@@ -39,15 +39,15 @@ public class Polygon extends MultiPoint {
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1737
|
||||
* @return stroke width as float
|
||||
*/
|
||||
public float getStrokeWidth() {
|
||||
float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
public void setFillAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
private void setFillAlpha(float alpha) {
|
||||
this.setAlpha(alpha);
|
||||
}
|
||||
|
||||
public void setFillColor(int color) {
|
||||
void setFillColor(int color) {
|
||||
fillColor = color;
|
||||
}
|
||||
|
||||
@@ -57,23 +57,27 @@ public class Polygon extends MultiPoint {
|
||||
*
|
||||
* @param holes
|
||||
*/
|
||||
public void setHoles(List<? extends List<LatLng>> holes) {
|
||||
void setHoles(List<? extends List<LatLng>> holes) {
|
||||
this.holes = new ArrayList<>();
|
||||
for (List<LatLng> hole : holes) {
|
||||
this.holes.add(new ArrayList<>(hole));
|
||||
}
|
||||
}
|
||||
|
||||
void addHole(List<LatLng> hole) {
|
||||
holes.add(hole);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alpha (opacity) of the stroke
|
||||
*
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
*/
|
||||
public void setStrokeAlpha(float alpha) {
|
||||
void setStrokeAlpha(float alpha) {
|
||||
strokeAlpha = alpha;
|
||||
}
|
||||
|
||||
public void setStrokeColor(int color) {
|
||||
void setStrokeColor(int color) {
|
||||
strokeColor = color;
|
||||
}
|
||||
|
||||
@@ -81,7 +85,7 @@ public class Polygon extends MultiPoint {
|
||||
* UNIMPLEMENTED: Needs implementation in Native.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/1737
|
||||
*/
|
||||
public void setStrokeWidth(float width) {
|
||||
void setStrokeWidth(float width) {
|
||||
strokeWidth = width;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PolygonOptions {
|
||||
public final class PolygonOptions {
|
||||
|
||||
protected Annotation annotation;
|
||||
private Polygon polygon;
|
||||
|
||||
public PolygonOptions() {
|
||||
annotation = new Polygon();
|
||||
polygon = new Polygon();
|
||||
}
|
||||
|
||||
public PolygonOptions add(LatLng point) {
|
||||
((MultiPoint)annotation).points.add(point);
|
||||
polygon.addPoint(point);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -40,22 +40,22 @@ public class PolygonOptions {
|
||||
* @param points - an iterable (list) of points for cutting a hole
|
||||
* @return PolygonOptions - the options object
|
||||
*/
|
||||
public PolygonOptions addHole (Iterable<LatLng> points) {
|
||||
private PolygonOptions addHole (Iterable<LatLng> points) {
|
||||
List<LatLng> hole = new ArrayList<>();
|
||||
for (LatLng point : points) {
|
||||
hole.add(point);
|
||||
}
|
||||
((Polygon)annotation).holes.add(hole);
|
||||
polygon.addHole(hole);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions alpha(float alpha) {
|
||||
annotation.alpha = alpha;
|
||||
polygon.setAlpha(alpha);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return annotation.alpha;
|
||||
return polygon.getAlpha();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,12 +65,12 @@ public class PolygonOptions {
|
||||
* @return PolygonOptions - the options object
|
||||
*/
|
||||
public PolygonOptions fillColor(int color) {
|
||||
((Polygon)annotation).fillColor = color;
|
||||
polygon.setFillColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getFillColor() {
|
||||
return ((Polygon)annotation).fillColor;
|
||||
return polygon.getFillColor();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,16 +79,19 @@ public class PolygonOptions {
|
||||
*
|
||||
* @return a list of lists of points for cutting holes
|
||||
*/
|
||||
public List<List<LatLng>> getHoles() {
|
||||
return ((Polygon)annotation).holes;
|
||||
private List<List<LatLng>> getHoles() {
|
||||
return polygon.getHoles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public Polygon getPolygon() {
|
||||
return ((Polygon)annotation);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
public int getStrokeColor() {
|
||||
return ((Polygon)annotation).strokeColor;
|
||||
return polygon.getStrokeColor();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,8 +100,8 @@ public class PolygonOptions {
|
||||
*
|
||||
* @return stroke width as float
|
||||
*/
|
||||
public float getStrokeWidth() {
|
||||
return ((Polygon)annotation).strokeWidth;
|
||||
private float getStrokeWidth() {
|
||||
return polygon.getStrokeWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +111,7 @@ public class PolygonOptions {
|
||||
* @return PolygonOptions - the options object
|
||||
*/
|
||||
public PolygonOptions strokeColor(int color) {
|
||||
((Polygon)annotation).strokeColor = color;
|
||||
polygon.setStrokeColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -118,23 +121,23 @@ public class PolygonOptions {
|
||||
*
|
||||
* @return stroke width as float
|
||||
*/
|
||||
public PolygonOptions strokeWidth(float width) {
|
||||
((Polygon)annotation).strokeWidth = width;
|
||||
private PolygonOptions strokeWidth(float width) {
|
||||
polygon.setStrokeWidth(width);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolygonOptions visible(boolean visible) {
|
||||
annotation.visible = visible;
|
||||
private PolygonOptions visible(boolean visible) {
|
||||
polygon.setVisible(visible);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return annotation.visible;
|
||||
private boolean isVisible() {
|
||||
return polygon.isVisible();
|
||||
}
|
||||
|
||||
public List<LatLng> getPoints() {
|
||||
// the getter gives us a copy, which is the safe thing to do...
|
||||
return ((MultiPoint)annotation).getPoints();
|
||||
return polygon.getPoints();
|
||||
}
|
||||
|
||||
// TODO: Implement writeToParcel of Google Maps Android API
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.mapbox.mapboxsdk.annotations;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
public class Polyline extends MultiPoint {
|
||||
public final class Polyline extends MultiPoint {
|
||||
|
||||
int color = Color.BLACK; // default color is black
|
||||
float width = 10; // As specified by Google API Docs (in pixels)
|
||||
private int color = Color.BLACK; // default color is black
|
||||
private float width = 10; // As specified by Google API Docs (in pixels)
|
||||
|
||||
public Polyline() {
|
||||
Polyline() {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Polyline extends MultiPoint {
|
||||
*
|
||||
* @param color - the color in ARGB format
|
||||
*/
|
||||
public void setColor(int color) {
|
||||
void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Polyline extends MultiPoint {
|
||||
*
|
||||
* @param width in pixels
|
||||
*/
|
||||
public void setWidth(float width) {
|
||||
void setWidth(float width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,16 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PolylineOptions {
|
||||
public final class PolylineOptions {
|
||||
|
||||
protected Annotation annotation;
|
||||
private Polyline polyline;
|
||||
|
||||
public PolylineOptions() {
|
||||
annotation = new Polyline();
|
||||
polyline = new Polyline();
|
||||
}
|
||||
|
||||
public PolylineOptions add(LatLng point) {
|
||||
((MultiPoint)annotation).points.add(point);
|
||||
polyline.addPoint(point);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ public class PolylineOptions {
|
||||
}
|
||||
|
||||
public PolylineOptions alpha(float alpha) {
|
||||
annotation.alpha = alpha;
|
||||
polyline.setAlpha(alpha);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return annotation.alpha;
|
||||
return polyline.getAlpha();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,29 +46,32 @@ public class PolylineOptions {
|
||||
* @param color - the color in ARGB format
|
||||
*/
|
||||
public PolylineOptions color(int color) {
|
||||
((Polyline)annotation).color = color;
|
||||
polyline.setColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return ((Polyline)annotation).color;
|
||||
return polyline.getColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method. Used internally by the SDK.
|
||||
*/
|
||||
public Polyline getPolyline() {
|
||||
return ((Polyline)annotation);
|
||||
return polyline;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return ((Polyline)annotation).width;
|
||||
return polyline.getWidth();
|
||||
}
|
||||
|
||||
public PolylineOptions visible(boolean visible) {
|
||||
annotation.visible = visible;
|
||||
PolylineOptions visible(boolean visible) {
|
||||
polyline.setVisible(visible);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return annotation.visible;
|
||||
private boolean isVisible() {
|
||||
return polyline.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,13 +81,13 @@ public class PolylineOptions {
|
||||
* @return a new PolylineOptions
|
||||
*/
|
||||
public PolylineOptions width(float width) {
|
||||
((Polyline)annotation).width = width;
|
||||
polyline.setWidth(width);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<LatLng> getPoints() {
|
||||
// the getter gives us a copy, which is the safe thing to do...
|
||||
return ((MultiPoint)annotation).getPoints();
|
||||
return polyline.getPoints();
|
||||
}
|
||||
|
||||
// TODO: Implement writeToParcel of Google Maps Android API
|
||||
|
||||
@@ -56,7 +56,6 @@ import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector;
|
||||
import com.almeros.android.multitouch.gesturedetectors.TwoFingerGestureDetector;
|
||||
import com.mapbox.mapboxsdk.R;
|
||||
import com.mapbox.mapboxsdk.annotations.Annotation;
|
||||
import com.mapbox.mapboxsdk.annotations.InfoWindow;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Polygon;
|
||||
@@ -1626,7 +1625,7 @@ public final class MapView extends FrameLayout {
|
||||
//setSprite(DEFAULT_SPRITE, bitmap);
|
||||
|
||||
// Red default marker is currently broken
|
||||
marker.setSprite("default_marker");
|
||||
//marker.setSprite("default_marker");
|
||||
//marker.setSprite(DEFAULT_SPRITE);
|
||||
}
|
||||
|
||||
@@ -1666,7 +1665,7 @@ public final class MapView extends FrameLayout {
|
||||
//setSprite(DEFAULT_SPRITE, bitmap);
|
||||
|
||||
// Red default marker is currently broken
|
||||
marker.setSprite("default_marker");
|
||||
//marker.setSprite("default_marker");
|
||||
//marker.setSprite(DEFAULT_SPRITE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user