Open
Description
Describe the bug
Using plyer gps, obtain gps co-ordinates of the phone. A simple center_on of the mapview makes the map go blank.
To Reproduce
Create a simple gps class to get the current location
class GpsHelper():
def run(self):
# Request permissions on Android
if platform == 'android':
from android.permissions import Permission, request_permissions
def callback(permission, results):
if all([res for res in results]):
print("Got all permissions")
from plyer import gps
gps.configure(on_location=self.print_location,
on_status=self.on_auth_status)
gps.start(minTime=1000, minDistance=0)
else:
print("Did not get all permissions")
request_permissions([Permission.ACCESS_COARSE_LOCATION,
Permission.ACCESS_FINE_LOCATION,
Permission.INTERNET,
Permission.WRITE_EXTERNAL_STORAGE,
Permission.READ_EXTERNAL_STORAGE], callback)
request_permissions([Permission.ACCESS_COARSE_LOCATION,
Permission.ACCESS_FINE_LOCATION,
Permission.INTERNET,
Permission.WRITE_EXTERNAL_STORAGE,
Permission.READ_EXTERNAL_STORAGE], callback)
def print_location(self, *args, **kwargs):
print(kwargs['lat'])
print(kwargs['lon'])
app = MDApp.get_running_app()
print(app.root.ids.mapcode)
#marker = app.root.ids.mapcode.ids.MapMarkerPopup
#marker.lat = kwargs['lat']
#marker.lon = kwargs['lon']
app.root.ids.mapcode.center_on(kwargs['lat'], kwargs['lat'])
app.root.ids.mapcode.zoom = 13
self.stop()
def stop(self):
gps.stop()
call it in the main app
from kivymd.app import MDApp
from mapcode import MapCode
from plyer import gps
from gpshelper import GpsHelper
class MainApp(MDApp):
def on_start(self):
gpsmanager = GpsHelper()
gpsmanager.run()
MainApp().run()
Works perfectly. The map gets recentred on getting the location when deployed on android. but then it goes blank and then even if i scroll or move around i see a blank map
Expected behavior
Should see the recentred map
Logs/output
No suspicious logs from logcat
Platform (please complete the following information):
- OS: [e.g. windows 10 /OSX 10.12 /linux/android 8/IOS 12…] Android
- Python version.
- release or git branch/commit
Additional context
Add any other context about the problem here.
Metadata
Assignees
Labels
No labels
Activity