Skip to content

Conversation

@n8han
Copy link
Collaborator

@n8han n8han commented Jan 14, 2020

As noted in issue #138, the default user location indicator is not
appearing in accordance with the myLocationRenderMode setting.
Instead, no indication of the user location appears when that location
is within the displayed map.

This is the relevant API documentation for the method used to override
annotation views:

The user location annotation view can also be customized via this
method. When annotation is an instance of MGLUserLocation (or equal
to the map view’s userLocation property), return an instance of
MGLUserLocationAnnotationView (or a subclass thereof).

https://docs.mapbox.com/ios/api/maps/5.6.1/Protocols/MGLMapViewDelegate.html#/Managing%20Annotation%20Views

From that it sounds like this controller behaves correctly by returning
"an instance" of MGLUserLocation, but perhaps the assumption is that
this instance will provide a specialized implementation. I wasn't able
to find any more information on this.

However, the return value for this function is optional. I found that
returning nil when a MGLUserLocation is requested resulted in the
location displaying with a dot as expected.

Note: MyLocationRenderMode.COMPASS is not supported, and as far as I
can tell it is not implemented within the Mapbox iOS SDK. Only a blue
dot with no direction arrow is provided. Other render modes may require
a custom iOS implementation in flutter-mapbox-gl.

As noted in issue flutter-mapbox-gl#138, the default user location indicator is not
appearing in accordance with the `myLocationRenderMode` setting.
Instead, no indication of the user location appears when that location
is within the displayed map.

This is the relevant API documentation for the method used to override
annotation views:

> The user location annotation view can also be customized via this
> method. When annotation is an instance of `MGLUserLocation` (or equal
> to the map view’s `userLocation` property), return an instance of
> `MGLUserLocationAnnotationView` (or a subclass thereof).

https://docs.mapbox.com/ios/api/maps/5.6.1/Protocols/MGLMapViewDelegate.html#/Managing%20Annotation%20Views

From that it sounds like this controller behaves correctly by returning
"an instance" of `MGLUserLocation`, but perhaps the assumption is that
this instance will provide a specialized implementation. I wasn't able
to find any more information on this.

However, the return value for this function is optional. I found that
returning `nil` when a MGLUserLocation is requested resulted in the
location displaying with a dot as expected.

Note: `MyLocationRenderMode.COMPASS` is not supported, and as far as I
can tell it is not implemented within the Mapbox iOS SDK. Only a blue
dot with no direction arrow is provided. Other render modes may require
a custom iOS implementation in flutter-mapbox-gl.
@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 14, 2020

@n8han I found the showsUserHeadingIndicator property in the MGLMapView class, could that help in implementing compass mode?

@n8han
Copy link
Collaborator Author

n8han commented Jan 15, 2020

@n8han I found the showsUserHeadingIndicator property in the MGLMapView class, could that help in implementing compass mode?

Nice find! Yes, setting showsUserHeadingIndicator does give the behavior I would expect for MyLocationRenderMode.COMPASS

That leaves MyLocationRenderMode.GPS, "Tracking the user location with bearing considered from Location". This would be "course" in the iOS SDK's terminology, as in MGLUserTrackingModeFollowWithCourse. I don't see anything for that in MGLMapView 😬. If it doesn't have built in support, I could still implement compass mode. Supporting 2 out of 3 render modes is better than 1, presumably.

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 15, 2020

I don't know a lot about iOS development, so I might be totally wrong here, but I found this https://github.com/mapbox/mapbox-gl-native-ios/blob/f489ec2ee131725b42162edf0414241f9c6310d1/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m#L49
I suspect this is the default implementation of the UserLocationAnnotationView (loaded here https://github.com/mapbox/mapbox-gl-native-ios/blob/309e226f7489693c06fad359c93911d8dca62435/platform/ios/src/MGLMapView.mm#L5505 if userLocationAnnotationView is null.
In that case we could probably either copy that class and modify it to allow for switching between the icon types independently from the userTrackingMode, or we could open an issue upstream asking them to implement such an API.
(Reading this PR it seems to me that it will be a lot of work to implement GPS mode ourselves, because the icon would have to render correctly on tilted maps)

@tobrun tobrun requested a review from TimothySealy January 20, 2020 19:09
@tobrun tobrun added the ios label Jan 20, 2020
@tobrun tobrun added this to the v0.1.0 milestone Jan 20, 2020
@tobrun
Copy link
Collaborator

tobrun commented Jan 20, 2020

We can follow up on GPS implementation as tailwork, great work @n8han! Thank you for contributing.

@n8han
Copy link
Collaborator Author

n8han commented Feb 3, 2020

👌 I'll open a PR to add the heading indicator after this one merges.

@tobrun tobrun merged commit 4623119 into flutter-mapbox-gl:master Feb 15, 2020
@tobrun
Copy link
Collaborator

tobrun commented Feb 15, 2020

Thank you for continuous support and contributions to the project @n8han, invited you as collaborator so you can directly push to this repo

Lobankovanastia pushed a commit to Lobankovanastia/flutter-mapbox-gl that referenced this pull request Feb 15, 2020
As noted in issue flutter-mapbox-gl#138, the default user location indicator is not
appearing in accordance with the `myLocationRenderMode` setting.
Instead, no indication of the user location appears when that location
is within the displayed map.

This is the relevant API documentation for the method used to override
annotation views:

> The user location annotation view can also be customized via this
> method. When annotation is an instance of `MGLUserLocation` (or equal
> to the map view’s `userLocation` property), return an instance of
> `MGLUserLocationAnnotationView` (or a subclass thereof).

https://docs.mapbox.com/ios/api/maps/5.6.1/Protocols/MGLMapViewDelegate.html#/Managing%20Annotation%20Views

From that it sounds like this controller behaves correctly by returning
"an instance" of `MGLUserLocation`, but perhaps the assumption is that
this instance will provide a specialized implementation. I wasn't able
to find any more information on this.

However, the return value for this function is optional. I found that
returning `nil` when a MGLUserLocation is requested resulted in the
location displaying with a dot as expected.

Note: `MyLocationRenderMode.COMPASS` is not supported, and as far as I
can tell it is not implemented within the Mapbox iOS SDK. Only a blue
dot with no direction arrow is provided. Other render modes may require
a custom iOS implementation in flutter-mapbox-gl.
@n8han n8han deleted the LocationRenderFix branch February 17, 2020 17:47
@n8han
Copy link
Collaborator Author

n8han commented Feb 17, 2020

Thank you for continuous support and contributions to the project @n8han, invited you as collaborator so you can directly push to this repo

Thanks so much! Should I continue to open PRs for all changes, or just those were I'm unsure and would like some feedback?

andrea689 added a commit to andrea689/flutter-mapbox-gl that referenced this pull request Mar 13, 2020
* master:
  Support setting map's content insets (flutter-mapbox-gl#215)
  Provide `onMapIdle` callback (flutter-mapbox-gl#214)
  [example] add full page map example (flutter-mapbox-gl#201)
  Fix missing location indicator on iOS (flutter-mapbox-gl#176)
  Returned a nil result so the future completes. (flutter-mapbox-gl#216)
  Update README: Access Tokens for self-hosted tiles (flutter-mapbox-gl#217)
  Change annotation priority (flutter-mapbox-gl#222)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants