summaryrefslogtreecommitdiff
path: root/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/PolylineOptions.java
blob: d825399f7d2a3b20c936d8498d0916f5da79790e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.mapbox.mapboxgl.annotations;

import com.mapbox.mapboxgl.geometry.LatLng;

import java.util.List;

public class PolylineOptions extends MultiPointOptions {

    public PolylineOptions() {
        annotation = new Polyline();
    }

    public PolylineOptions add(LatLng point) {
        ((MultiPoint)annotation).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;
    }

    /**
     * Sets the color of the polyline.
     *
     * @param color - the color in ARGB format
     */
    public PolylineOptions color(int color) {
        ((Polyline)annotation).color = color;
        return this;
    }

    public int getColor() {
        return ((Polyline)annotation).color;
    }

    public Polyline getPolyline() {
        return ((Polyline)annotation);
    }

    public float getWidth() {
        return ((Polyline)annotation).width;
    }

    public PolylineOptions visible(boolean visible) {
        annotation.visible = visible;
        return this;
    }

    /**
     * Sets the width of the polyline.
     *
     * @param width in pixels
     * @return
     */
    public PolylineOptions width(float width) {
        ((Polyline)annotation).width = width;
        return this;
    }

    // TODO: Implement writeToParcel of Google Maps Android API
//    public void writeToParcel(Parcel out, int flags) {
//
//    }

}