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

MapboxMapController requestMyLocationLatLng implementation missing #423

Closed
loxodrome21 opened this issue Sep 29, 2020 · 14 comments
Closed
Labels

Comments

@loxodrome21
Copy link

loxodrome21 commented Sep 29, 2020

Hi,

There used to be an implementation of the method requestMyLocationLatLng in lib/src/controller.dart:

Future<LatLng> requestMyLocationLatLng() async {
    try {
      final Map<Object, Object> reply = await _channel.invokeMethod(
          'locationComponent#getLastLocation', null);
      double latitude = 0.0, longitude = 0.0;
      if (reply.containsKey("latitude") && reply["latitude"] != null) {
        latitude = double.parse(reply["latitude"].toString());
      }
      if (reply.containsKey("longitude") && reply["longitude"] != null) {
        longitude = double.parse(reply["longitude"].toString());
      }
      return LatLng(latitude, longitude);
    } on PlatformException catch (e) {
      return new Future.error(e);
    }
}

It was changed in this commit Web implementation (#223) to:

Future<LatLng> requestMyLocationLatLng() async {
    return MapboxGlPlatform.getInstance(_id).requestMyLocationLatLng();
}

which is not yet implemented in lib/src/mapbox_gl_platform_interface.dart:

Future<LatLng> requestMyLocationLatLng() async {
    throw UnimplementedError( 'requestMyLocationLatLng() has not been implemented.');
}

Is there any workaround or plugin implementing this function? I am interested in iOS and Android implementations.

Thanks,
Carlos

@m0nac0
Copy link
Collaborator

m0nac0 commented Oct 4, 2020

@loxodrome21 Hi,
the lib/src/mapbox_gl_platform_interface.dart is actually just an abstract interface, the implementation we are using for android and iOS lives in mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart.
That contains the following code: https://github.com/tobrun/flutter-mapbox-gl/blob/10788a7224ae8edd191bcef68e49d03e194c1058/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart#L356-L371
Have you tested requestMyLocationLatLng() on Android and iOS and do they actually throw an UnimplementedError?

@AAverin
Copy link
Contributor

AAverin commented Oct 14, 2020

@m0nac0 in the linked ticket #405 you can also see that getLastLocation seems to be missing on iOS, this is probably related?

@AAverin
Copy link
Contributor

AAverin commented Oct 25, 2020

At the moment 'locationComponent#getLastLocation' implementation is not present in MapboxMapController.swift

@AAverin
Copy link
Contributor

AAverin commented Oct 25, 2020

Thought it would be easy to just grab location from mapView?.userLocation?.location, but it delivers lat=0, lon=0 even though user location is displayed on the map and permission is there. Would be great if someone with more iOS experience could take a look.

@leeprobert
Copy link

Did you ever resolve this issue? I am still getting this error on MapboxMapController.requestMyLocationLatLng - getLastLocation is not implemented.

@AAverin
Copy link
Contributor

AAverin commented Jun 10, 2021

There is no "resolution". Somebody with the knowledge of how iOS work needs to implement method 'locationComponent#getLastLocation' and make a pull request.

@leeprobert
Copy link

Ok. I might be able to do this. I will need to if it is preventing any way of showing the user location in my Flutter app. Will get back to you.

@stale
Copy link

stale bot commented Jan 14, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 14, 2022
@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 14, 2022

Seems to still be relevant.

@stale stale bot removed the stale label Jan 14, 2022
@stale
Copy link

stale bot commented Mar 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 15, 2022
@AAverin
Copy link
Contributor

AAverin commented Mar 15, 2022

Still missing, contribution from iOS devs is needed here.

@stale stale bot removed the stale label Mar 15, 2022
@felix-ht
Copy link
Collaborator

I actually thing that i would be better to just deprecate this function and let users use some external package

@AAverin
Copy link
Contributor

AAverin commented Mar 16, 2022

I also had this thought. We could also use some external package internally to build this functionality into the library.
But the map would need to update location indicator somehow too and this location stuff is already implemented by the native libraries anyways.

@stale
Copy link

stale bot commented May 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 15, 2022
@stale stale bot closed this as completed May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants