-
Notifications
You must be signed in to change notification settings - Fork 510
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
Add custom user location marker #571
Comments
I am also very interested in this one. |
Yeah, the underlying SDKs support this, but it's not currently implemented/exposed in this plugin. |
We have used flutter_compass together with a listener on the MapboxMapController. From the docs of the controller:
The cameraPosition property contains a bearing field which we added to a StreamController's ( final headingStream = FlutterCompass.events
.map((event) => event.heading)
.throttleTime(Duration(milliseconds: 16));
final bearingStream =
mapCameraBearing.stream.throttleTime(Duration(milliseconds: 16));
final rotationStream = CombineLatestStream.combine2<double, double, double>(
headingStream, bearingStream, (heading, bearing) {
return heading + ((360 - bearing) % 360);
}).scan((double acc, double curr, _) {
// Checks the last emitted value against a potential new value
// If difference is greater than 1 degree, emit the new value
// Otherwise emit the old value.
const epsilon = 1;
final diff = (acc - curr).abs();
final isIgnored = diff < epsilon || (diff - 360).abs() < epsilon;
return isIgnored ? acc : curr;
}, 0.0).distinct(); Then we listen on the You could listen for the map's tilt in the same way as is done with the bearing of it here, although I don't think Symbol exposes options to tilt an icon on the map. The above approach works somewhat well but the rotation when turning the map always trails behind maybe half a second or so which is enough for our usecase but may not be for everyone. I agree however that this would be a great addition for mapbox in flutter because it solves a bunch of problems currently bandaided by using third party plugins. |
@geisterfurz007 Thank you for this suggestion, I very much appreciate that! It's very helpful but I will keep the default markers from Mapbox for now and try it out another time if there's still no way to handle it through the SDK. |
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. |
Keep it open. |
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. |
Open issue again, stale bot! |
Some ideas: Might be a good idea to add something like a LocationMarkerStyle class. This might hold eg:
|
I've been searching for a way to add a custom user location marker but haven't found a specific solution yet.
So far I have found #477 which recommends grabbing the location independently and add the symbol to the map. But what I don't understand is: If you get the location independently from another library how does the library know about rotation and tilting within Mapbox and in which direction I am heading (so the arrow on my custom location marker is not always pointing to the north)?
The location marker on Android is different than on iOS and I'd like to have them unified and customized. The Mapbox Doc for iOS on "Customize the user location annotation" suggests using
CustomUserLocationAnnotationView
in Swift. And for Android I have found this documentation.Isn't there another solution other than modifying the user location annotation in the Java and Swift files?
Thank you :)
The text was updated successfully, but these errors were encountered: