center map on current location

This commit is contained in:
rgarcia-herrera 2020-08-11 11:31:25 -05:00
parent ab5a918f2c
commit 6fdb20e8bd
2 changed files with 17 additions and 4 deletions

View File

@ -18,6 +18,10 @@
ActionPrevious:
title: 'Social Cycling'
with_previous: False
ActionButton:
important: False
text: 'go to current loc'
on_press: app.center_map_on_gps()
ActionButton:
important: True
text: 'we ride together'

17
main.py
View File

@ -82,8 +82,17 @@ class FlockompassApp(App):
self.fbearing = self.needle_angle + degrees(self.fbearing)
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):
needle_angle = 7
"""
get magnetic field for compass
"""
needle_angle = 0
if self.cs.facade.field != (None, None, None):
self.x_calib, self.y_calib, self.z_calib = self.cs.facade.field
x, y, z = self.cs.facade.field
@ -102,13 +111,13 @@ class FlockompassApp(App):
if self.cs._anim:
self.cs._anim.stop(self)
self.cs._anim = Animation(needle_angle=needle_angle,
d=0.2,
t='out_quad')
d=0.1,
t='out_elastic')
self.cs._anim.start(self)
def compass_enable(self):
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):
self.cs.facade.disable()