center map on current location
This commit is contained in:
parent
ab5a918f2c
commit
6fdb20e8bd
@ -18,6 +18,10 @@
|
|||||||
ActionPrevious:
|
ActionPrevious:
|
||||||
title: 'Social Cycling'
|
title: 'Social Cycling'
|
||||||
with_previous: False
|
with_previous: False
|
||||||
|
ActionButton:
|
||||||
|
important: False
|
||||||
|
text: 'go to current loc'
|
||||||
|
on_press: app.center_map_on_gps()
|
||||||
ActionButton:
|
ActionButton:
|
||||||
important: True
|
important: True
|
||||||
text: 'we ride together'
|
text: 'we ride together'
|
||||||
|
|||||||
17
main.py
17
main.py
@ -82,8 +82,17 @@ class FlockompassApp(App):
|
|||||||
self.fbearing = self.needle_angle + degrees(self.fbearing)
|
self.fbearing = self.needle_angle + degrees(self.fbearing)
|
||||||
self.fbearing = (self.fbearing + 360) % 360
|
self.fbearing = (self.fbearing + 360) % 360
|
||||||
|
|
||||||
|
def center_map_on_gps(self):
|
||||||
|
self.ms.ids.mapview.center_on(self.gps_data['lat'],
|
||||||
|
self.gps_data['lon'])
|
||||||
|
|
||||||
|
|
||||||
def get_field(self, dt):
|
def get_field(self, dt):
|
||||||
needle_angle = 7
|
"""
|
||||||
|
get magnetic field for compass
|
||||||
|
"""
|
||||||
|
|
||||||
|
needle_angle = 0
|
||||||
if self.cs.facade.field != (None, None, None):
|
if self.cs.facade.field != (None, None, None):
|
||||||
self.x_calib, self.y_calib, self.z_calib = self.cs.facade.field
|
self.x_calib, self.y_calib, self.z_calib = self.cs.facade.field
|
||||||
x, y, z = self.cs.facade.field
|
x, y, z = self.cs.facade.field
|
||||||
@ -102,13 +111,13 @@ class FlockompassApp(App):
|
|||||||
if self.cs._anim:
|
if self.cs._anim:
|
||||||
self.cs._anim.stop(self)
|
self.cs._anim.stop(self)
|
||||||
self.cs._anim = Animation(needle_angle=needle_angle,
|
self.cs._anim = Animation(needle_angle=needle_angle,
|
||||||
d=0.2,
|
d=0.1,
|
||||||
t='out_quad')
|
t='out_elastic')
|
||||||
self.cs._anim.start(self)
|
self.cs._anim.start(self)
|
||||||
|
|
||||||
def compass_enable(self):
|
def compass_enable(self):
|
||||||
self.cs.facade.enable()
|
self.cs.facade.enable()
|
||||||
Clock.schedule_interval(self.get_field, 1 / 5.0)
|
Clock.schedule_interval(self.get_field, 1 / 10.0)
|
||||||
|
|
||||||
def compass_disable(self):
|
def compass_disable(self):
|
||||||
self.cs.facade.disable()
|
self.cs.facade.disable()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user