• Hi!
    I m using the following shortcode in order to show a track from a gpx file:

    [leaflet-map lat=41.25229817166762 lng=2.6779601097922616 zoom=9 zoomcontrol detect-retina]

    [leaflet-marker visible]ARGO[/leaflet-marker]

    [leaflet-gpx src=https://tracking.argo-yacht.de/test-track.gpx color=black]

    The map and the leaflet-marker are shown fine. But unfortunately the track from the linked gpx file is not shown. I have tested this gpx file on an online gpx file tester and it seems to be fine.

    What could be the reason?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor hupe13

    (@hupe13)

    Is the track near enough to the marker? Try [leaflet-map lat=... lng=... zoomcontrol detect-retina fitbounds].

    Does the URL of the trackfile exist?

    Does the webserver return the correct mime type (application/gpx+xml)?
    Put in your .htaccess:

    AddType application/gpx+xml gpx
    RewriteRule .*.gpx$ – [L,T=application/gpx+xml]

    Thread Starter dosheimer

    (@dosheimer)

    Hi! Thanks for response.
    It was a CORS problem. Moving the gpx file onto the same domain solved it. The track is being shown now, very nice.

    Is there a way to show the youngest waypoint within the gpx file as a marker on the map (to show this as the current location)?

    • This reply was modified 1 year, 6 months ago by dosheimer.
    Plugin Contributor hupe13

    (@hupe13)

    Is there a way to show the youngest waypoint within the gpx file as a marker on the map (to show this as the current location)?

    It is possible, but it need some php knowlegde. So I read the starting point in a gpx file:

    $gpx = simplexml_load_file($file);
    $latlng = array(
      (float)$gpx->trk->trkseg->trkpt[0]->attributes()->lat,
      (float)$gpx->trk->trkseg->trkpt[0]->attributes()->lon,
    );
    • This reply was modified 1 year, 6 months ago by hupe13.
    • This reply was modified 1 year, 6 months ago by hupe13.
    Thread Starter dosheimer

    (@dosheimer)

    hm shit, I only have basic php knowledge.

    So I ws thinking to write the youngest GPS position into another file, this time into a .kml instead of a .gpx file. As this is what I can do in php.

    Then I would use something like this:
    [leaflet-kml src=https://www………./…./current-position.kml fillColor=red color=white]

    This seems to work fine: The track from the gpx-file is being shown and also the current position marker from the kml file. But how do I center the map around this kml current position marker?

    • This reply was modified 1 year, 6 months ago by dosheimer.
    • This reply was modified 1 year, 6 months ago by dosheimer.
    • This reply was modified 1 year, 6 months ago by dosheimer.
    Thread Starter dosheimer

    (@dosheimer)

    That′s what I have so far, but the map is not centered around the marker from the kml file.

    [leaflet-map fitbounds]

    [leaflet-gpx src=https://www……/…./test-track.gpx color=blue]

    [leaflet-kml src=https://www……/…../current-position.kml]

    Plugin Contributor hupe13

    (@hupe13)

    You can use Extensions for Leaflet Map and test my documentation.

    [leaflet-map !fitbounds ...]
    [leaflet-gpx !fitbounds ...]track[/leaflet-gpx]
    [leaflet-kml fitbounds ...]Point[/leaflet-kml]
    [zoomhomemap !fit]

    The problem is now, that one point in the kml file is bad for fitbounds, a marker does not have bounds. Or can you write this point as a marker and use

    [leaflet-map lat=... lng=... zoom=...]
    [leaflet-marker]Point[/leaflet-marker]

    It needs some tests and ideas.

    Thread Starter dosheimer

    (@dosheimer)

    Thank you for this.

    I am using the map for my offshore sailing adventures. I just reduced the gpx track file to be only for 2 weeks in the past by a cron job and php. So I can live with the issue that the map currently centers the map it seems more or less in the middle of the track (?).

    But now another issue occured: When I am not moving the boat, the track of cause is very close to the boat. And then the map is zooming heavily into the map. This generlly is no problem, but the map is no more shown, it is gray. If I then zoom out a bit the map is shown again.

    So it seems to be some kind of overzoom.

    Is there a chance to set a zoom level manually by using shortcode in this context? That′s my current shortcode:
    —————-
    [leaflet-map fitbounds zoomcontrol detect-retina]

    [leaflet-kml src=https://www……/……/current-position.kml]

    [leaflet-gpx src=https://www……../……/track.gpx color=blue]
    ————-

    • This reply was modified 1 year, 6 months ago by dosheimer.
    Plugin Contributor hupe13

    (@hupe13)

    This is this, what I mean: a marker has not bounds. So it zooms to the marker with the highest zoom level. Are you using openstreetmap.org? Set in the settings for Leaflet Map Default Max Zoom to 19.

    Thread Starter dosheimer

    (@dosheimer)

    Thanks. Now I changed to standard zoom level 19 in the “Leaflet Map” wordpress plugin settings.

    But unfortunately the map is not reacting on that.

    Any further ideas?

    By the way: I found a way to execute php code within a wordpress page. So just in case you would have a suggestion to change this zoom level via php code I could give it at least a try.

    And yes, I am using openstreetmap.org for the maps

    • This reply was modified 1 year, 6 months ago by dosheimer.
    Plugin Contributor hupe13

    (@hupe13)

    Omit detect-retina.

    Thread Starter dosheimer

    (@dosheimer)

    i tried, not getting better.

    Thread Starter dosheimer

    (@dosheimer)

    I just tried more around with the min/max and standard zoomlevels in the Plugin settings. I did not really got behind the idea, but anyway it is working now in an acceptable way.

    Many many thanks for your kind support!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘gpx file track not shown’ is closed to new replies.