mpetazzoni / leaflet-gpx

A GPX track plugin for Leaflet.js
http://mpetazzoni.github.io/leaflet-gpx
BSD 2-Clause "Simplified" License
550 stars 119 forks source link

GPX data seems consistently offset to the north #152

Closed simplicitywebdesign closed 8 months ago

simplicitywebdesign commented 8 months ago

Screenshot 2024-03-10 at 23 09 53 The track shows successfully however the points aren't mapped accurately. There is a consistent offset. I have tried multiple GPX files from different sensors (Garmin and iPhone) and the offset seems consistent at each zoom level. As you zoom in, the inaccuracy is lessened. I'm at a loss to explain it. I'm still in local development but can provide code if needed, didn't post it to begin with as it's a GPX file so would be too big to paste in here. Suffice to say I'm not doing any processing of the GPX except for your script.

mpetazzoni commented 8 months ago

@simplicitywebdesign You can attach files to an issue by just drag-n-drop'ing them here. Would you mind share that GPX file so I can try for myself? This is very interesting indeed.

mpetazzoni commented 8 months ago

This could be a projection issue, which is more visible the further away from the equator you are. With that said, Tasmania is 41°S, and Northern California (where I'm at and I tested with some of my GPX from this area) is about 41°N, so no difference there 🤷🏻

Either that, or it's the basemap tiles that are off? Have you tried other layers?

simplicitywebdesign commented 8 months ago

Sure: https://assets.ryanmoore.au/gpx/tassie-combined.gpx

I am hoping it's something stupid I'm doing. It seems to be consistently 24–25 pixels to "the north"/top.

mpetazzoni commented 8 months ago

Confirmed it's an issue with the base layer, with the default OSM layer it's fine and aligned correctly:

image

Also fine on the CyclOSM base map:

image
mpetazzoni commented 8 months ago

@simplicitywebdesign Which base layer are you using in your example?

simplicitywebdesign commented 8 months ago

Hi Maxime, thanks for looking into this with me. You're right, it's definitely something off about the base layer, and in that spirit I had tried swapping out Thunderforest/OSM/etc without joy and gone down the rabbit hole of thinking my GPX coords were off, and I think I've skipped over the simpler possibility: a conflicting style or script on the site itself. I have set up a little sandbox with just the map code and it displays fine. I'll have to go back and dig for the culprit.

Update: Yes, some other lazy plugin dev (shall remain nameless, but I've posted a PR) has used the dreaded selector combined with a [class="overlay"] to add a margin and that was pushing out the overlay div. Grrrr...

mpetazzoni commented 8 months ago

@simplicitywebdesign Thanks for the follow-up! I have to admit CSS wasn't the root cause I was expecting!