-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapUtils.py
More file actions
119 lines (94 loc) · 3.75 KB
/
MapUtils.py
File metadata and controls
119 lines (94 loc) · 3.75 KB
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
113
114
115
116
117
118
119
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import AsyncImage
from kivy.uix.label import Label
from kivy.uix.bubble import Bubble
from kivy_garden.mapview import MapMarkerPopup
class CustomMarkerBase(MapMarkerPopup):
marker_pressed_pois = False
marker_pressed_cams = False
marker_pressed_constructions = False
marker_type = "CAM"
marker_instance = None
def __init__(self, marker_list_pois, marker_list_cams, marker_list_constructions, **kwargs):
super().__init__(**kwargs)
self.marker_list_pois = marker_list_pois
self.marker_list_cams = marker_list_cams
self.marker_list_constructions = marker_list_constructions
self.bind(on_touch_move=self.open)
self.bind(on_touch_up=self.open)
def open(self, *args):
if self.marker_type == "CAM":
marker_list = self.marker_list_cams
marker_pressed = CustomMarkerBase.marker_pressed_cams
elif self.marker_type == "POI":
marker_list = self.marker_list_pois
marker_pressed = CustomMarkerBase.marker_pressed_pois
else:
marker_list = self.marker_list_constructions
marker_pressed = CustomMarkerBase.marker_pressed_constructions
if marker_pressed:
for marker in marker_list:
if CustomMarkerBase.marker_instance is marker:
CustomMarkerBase.marker_instance.open_popup()
else:
marker.close_popup()
else:
for marker in marker_list:
marker.open_popup()
def on_press(self, *args):
CustomMarkerBase.marker_instance = self
if self.marker_type == "CAM":
marker_pressed = CustomMarkerBase.marker_pressed_cams
if marker_pressed:
marker_pressed = False
else:
marker_pressed = True
CustomMarkerBase.marker_pressed_cams = marker_pressed
elif self.marker_type == "POI":
marker_pressed = CustomMarkerBase.marker_pressed_pois
if marker_pressed:
marker_pressed = False
else:
marker_pressed = True
CustomMarkerBase.marker_pressed_pois = marker_pressed
else:
marker_pressed = CustomMarkerBase.marker_pressed_constructions
if marker_pressed:
marker_pressed = False
else:
marker_pressed = True
CustomMarkerBase.marker_pressed_constructions = marker_pressed
def close_popup(self):
self.is_open = False
self.refresh_open_status()
def open_popup(self):
self.is_open = True
self.refresh_open_status()
class CustomMarkerPois(CustomMarkerBase):
marker_type = "POI"
class CustomMarkerCams(CustomMarkerBase):
marker_type = "CAM"
class CustomMarkerConstructionAreas(CustomMarkerBase):
marker_type = "CONSTRUCTION"
class CustomAsyncImage(AsyncImage):
def __init__(self, **kwargs):
super().__init__(**kwargs)
class CustomBubble(Bubble):
def __int__(self, **kwargs):
super.__init__(**kwargs)
class CustomLabel(Label):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def update_text(self, *args):
c_text = self.__customize_text(*args)
self.text = c_text
self.texture_update()
@staticmethod
def __customize_text(*args):
customized_string = ""
for arg in args:
customized_string = "\n".join((customized_string, arg))
return customized_string
class CustomLayout(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)