/
marker.go
70 lines (56 loc) · 1.51 KB
/
marker.go
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
package models
import "log"
// Marker provides all necessary elements to the front to display a track
//
// L.Marker is used to display clickable/draggable icons on the map. Extends Layer.
//
// swagger:model Marker
type Marker struct {
Lat, Lng float64
Name string
ColorEnum ColorEnum
// LayerGroup the object belongs to
LayerGroup *LayerGroup
// DivIcon
DivIcon *DivIcon
// swagger:ignore
// access to the models instance that contains the original information
MarkerInteface MarkerInterface `gorm:"-"`
// the Stage_ of the visual track
Stage_ *StageStruct
}
type MarkerInterface interface {
GetLat() (lat float64)
GetLng() (lng float64)
GetName() (name string)
GetLayerGroupName() string
}
func (marker *Marker) UpdateMarker() {
if marker.MarkerInteface != nil {
marker.Name = marker.MarkerInteface.GetName()
marker.Lat = marker.MarkerInteface.GetLat()
marker.Lng = marker.MarkerInteface.GetLng()
marker.LayerGroup =
ComputeLayerGroupFromLayerGroupName(
marker.Stage_,
marker.MarkerInteface.GetLayerGroupName())
}
}
// attach visual center to center
func AttachMarker(
gongleafletStage *StageStruct,
markerInterface MarkerInterface,
colorEnum ColorEnum,
divIcon *DivIcon) (marker *Marker) {
// check icon is present
if divIcon == nil {
log.Fatal("nil visual icon")
}
marker = new(Marker).Stage(gongleafletStage)
marker.MarkerInteface = markerInterface
marker.ColorEnum = colorEnum
marker.DivIcon = divIcon
marker.Stage_ = gongleafletStage
marker.UpdateMarker()
return
}