Skip to content

Conversation

depau
Copy link

@depau depau commented Sep 14, 2025

Hi!
This is a preliminary PoC implementation that adds handling of Z-index and polyline spans to the MapBox map implementation.

It isn't thoroughly tested, though it should fix some of the annoying glitches reported in #2382. Primarily it fixes my annoyance with Garmin Connect not actually displaying the run stats on the map.

I'm not a huge fan of the implementation, I basically did the least amount of work to get the feature going as a proof of concept to make sure this was even possible with the MapLibre API. If you'd like to integrate it I'm open to guidance and suggestions on how to properly implement it.

I also implemented JointType handling.

Before:
image

After:

image

Website (just as a reference, I currently don't have a device with GApps to test):

image

The reason why the colors are slightly different in this image is that I ran multiple times in the same spots. I'll need to compare with the Google Android implementation since I think their web implementation is a bit messy.

EDIT:

Google Maps vs microG:

image

I think the result is very acceptable.

@depau
Copy link
Author

depau commented Sep 14, 2025

A little explanation is probably necessary to understand some of the main choices:

  • To add multiple line segments I could have either split polylines into multiple polyline objects or, as I did, introduce support for multiple annotations into Markup. I went for the latter since I thought it would be the least effort.
  • I didn't put too much effort into cleaning up the code that performs polyline updates, it's probably not very efficient
  • With the version of MapLibre in use the only way to control the stacking of annotations is to create multiple managers, since each gets signed its layer id and since we can specify above/below which other layers it should go.
  • The routine that fetches the correct Line/Segment/Fill Manager for the given Z index uses a TreeMap to compute the layers stacking. The idea is that the underlying tree's inherent ordering properties make it easy to insert a layer at any position in the layer stack, determining the layer above/below quickly. The situation might get a bit messy when apps insert layers like crazy but my intuition is that the layer ordering should stay visually consistent.

@depau
Copy link
Author

depau commented Sep 15, 2025

I finally implemented geodesic polyline. Disclaimer: for this part I used AI extensively since I don't fully understand the math. If you'd rather exclude this let me know.

image

At this point I don't think there's a lot more functionality we're missing that can be implemented. Tile overlays are basically impossible to add, and respecting the user's requested start/end cap style is very cumbersome with the MapLibre API. So I think I'm done, once somebody gets the change to take a look I can clean it up and get it ready for upstreaming if you'd like to get these changes in.

@mar-v-in mar-v-in requested a review from fynngodau September 16, 2025 09:04
@mar-v-in mar-v-in added this to the 0.3.11 milestone Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants