osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

Map is always loading when controller is initialized with initMapWithUserPosition as true

Open praveen-gm opened this issue 4 years ago • 13 comments

Hi, When the controller is initialized with initMapWithUserPosition as true, the map keeps loading

 final MapController _mapController = MapController(
    initMapWithUserPosition: true,
  );

Steps to reproduce on the latest flutter_osm_plugin: ^0.30.1+2

on the example app, change controller initialization initMapWithUserPosition to true.

Tested on Samsung A10s (Android 11) and iPhone SE (iOS 14.7.1), Although it worked on the Android Emulator on the second launch, the first launch gave these errors while the permission dialog popped up

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null, null) E/flutter (32151): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7) E/flutter (32151): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18) E/flutter (32151): E/flutter (32151): #2 MethodChannelPermissionHandler.requestPermissions (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:71:9) E/flutter (32151): E/flutter (32151): #3 PermissionActions.request (package:permission_handler/permission_handler.dart:44:31) E/flutter (32151): E/flutter (32151): #4 MobileOsmFlutterState.requestPermission (package:flutter_osm_plugin/src/widgets/mobile_osm_flutter.dart:220:30) E/flutter (32151): E/flutter (32151): #5 MobileOSMController.initMap (package:flutter_osm_plugin/src/controller/osm/osm_controller.dart:209:24) E/flutter (32151): E/flutter (32151): #6 BaseMapController.init. (package:flutter_osm_interface/src/map_controller/base_map_controller.dart:50:7) E/flutter (32151):

Many thanks for creating this wonderful package, Please do let me know if you want me to share any further info/logs.

praveen-gm avatar Feb 18 '22 10:02 praveen-gm

i will check that and i will fix it

liodali avatar Feb 18 '22 12:02 liodali

you face the same problem in iOS ?

liodali avatar Feb 18 '22 15:02 liodali

yes, I faced the same problem in iOS

praveen-gm avatar Feb 18 '22 16:02 praveen-gm

in iOS doesn't show you popup for permission ? or it shows and even if you grant the permission the map doesn't show because for android , yes i confirm that their is a problem and already fixed i will make commit and it will available with new release 0.31.0

liodali avatar Feb 18 '22 16:02 liodali

I had it just verified, iOS didn't show the permission popup

praveen-gm avatar Feb 18 '22 16:02 praveen-gm

for iOS, did you check that location is on ?

liodali avatar Feb 18 '22 16:02 liodali

yes, location services enabled

On Fri, Feb 18, 2022, 10:25 PM hamza mohamed ali @.***> wrote:

for iOS, did you check that location is on ?

— Reply to this email directly, view it on GitHub https://github.com/liodali/osm_flutter/issues/232#issuecomment-1044832441, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIX7KHL3L35DPWQP3BCLADDU3Z2XJANCNFSM5OXNSJOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

praveen-gm avatar Feb 18 '22 17:02 praveen-gm

for iOS, did you add those lines in info.plist ?

   <key>NSLocationWhenInUseUsageDescription</key>
	<string>any text you want</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>any text you want</string>

liodali avatar Feb 18 '22 17:02 liodali

iOS permission was already granted, my bad restarted iPhone and the map worked on the iPhone

I got it working on Android, Now I can be more precise on reproducing this bug on Android. There's this Google's FusedLocationProviderClient that I've used in a different native app. When you try to get the lastLocation sometimes it doesn't return any result due to various reasons such as no lastLocation available or turning off/on the GPS clears cache etc.

So, I opened the google maps so it would cache the lastLocation and then opened the sample app, then the maps loaded, otherwise it kept loading

praveen-gm avatar Feb 19 '22 02:02 praveen-gm

for android like i told you i fix that bug, i will publish new version this weekend that contain this fix and other feature

liodali avatar Feb 19 '22 09:02 liodali

Thank you for the quick fix.

praveen-gm avatar Feb 19 '22 10:02 praveen-gm

check the new version 0.31.0

liodali avatar Feb 19 '22 17:02 liodali

Thank you very much, this bug has been resolved. I'll close this issue

praveen-gm avatar Feb 20 '22 03:02 praveen-gm