Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple center_on command displays blank map on android #61

Open
krchug opened this issue Nov 30, 2022 · 0 comments
Open

Simple center_on command displays blank map on android #61

krchug opened this issue Nov 30, 2022 · 0 comments

Comments

@krchug
Copy link

krchug commented Nov 30, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant