summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java
blob: 4f88cb038fd4fa1adf9081ae89d4be95cbfa30c5 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.mapbox.mapboxsdk.annotations;

import android.graphics.Point;
import android.graphics.PointF;

import com.mapbox.mapboxsdk.maps.MapboxMap;

public class MarkerView extends Marker {

    private MarkerViewManager markerViewManager;

    private PointF centerOffset;
    private Point infoWindowOffset;
    private boolean flat;

    private int selectAnimRes;
    private int deselectAnimRes;

    private float tiltValue;
    private float rotation;
    private float alpha = 1;

    MarkerView() {
        centerOffset = new PointF();
        infoWindowOffset = new Point();
    }

    public MarkerView(BaseMarkerViewOptions baseMarkerViewOptions) {
        super(baseMarkerViewOptions);
        this.centerOffset = baseMarkerViewOptions.getCenterOffset();
        this.infoWindowOffset = baseMarkerViewOptions.getInfoWindowOffset();
        this.flat = baseMarkerViewOptions.isFlat();
        this.selectAnimRes = baseMarkerViewOptions.getSelectAnimRes();
        this.deselectAnimRes = baseMarkerViewOptions.getDeselectAnimRes();
    }

    public PointF getCenterOffset() {
        return centerOffset;
    }

    public void setCenterOffset(PointF centerOffset) {
        this.centerOffset = centerOffset;
    }

    public Point getInfoWindowOffset() {
        return infoWindowOffset;
    }

    public void setInfoWindowOffset(Point infoWindowOffset) {
        this.infoWindowOffset = infoWindowOffset;
    }

    public boolean isFlat() {
        return flat;
    }

    public void setFlat(boolean flat) {
        this.flat = flat;
    }

    public int getSelectAnimRes() {
        return selectAnimRes;
    }

    public void setSelectAnimRes(int selectAnimRes) {
        this.selectAnimRes = selectAnimRes;
    }

    public int getDeselectAnimRes() {
        return deselectAnimRes;
    }

    public void setDeselectAnimRes(int deselectAnimRes) {
        this.deselectAnimRes = deselectAnimRes;
    }

    float getTilt() {
        return tiltValue;
    }

    void setTilt(float tiltValue) {
        this.tiltValue = tiltValue;
    }

    public void setRotation(float rotation) {
        this.rotation = rotation;
        if (markerViewManager != null) {
            markerViewManager.animateRotation(this, rotation);
        }
    }

    public float getRotation() {
        return rotation;
    }

    public float getAlpha() {
        return alpha;
    }

    public void setAlpha(float alpha) {
        this.alpha = alpha;
        if (markerViewManager != null) {
            markerViewManager.animateAlpha(this, alpha);
        }
    }

    @Override
    public void setMapboxMap(MapboxMap mapboxMap) {
        super.setMapboxMap(mapboxMap);
        markerViewManager = mapboxMap.getMarkerViewManager();
    }
}