Linux 软件免费装
Banner图

GPX Route Map

开发者 sirlouen
更新时间 2026年10月7日 18:29
PHP版本: 7.4 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

map gpx route openstreetmap elevation

下载

2.0.0 1.3.0 1.0.0 1.1.0 1.2.0 1.2.1 1.4.0 1.5.0 1.6.0 1.6.1 1.7.0 1.8.0

详情介绍:

GPX Route Map turns a GPX file into an interactive map on the front end of your site. Drop the block into any post or page, pick a .gpx file, and visitors get: The map loads lazily (only when it scrolls into view) so it never slows down your page, and multiple maps can live on the same page. You can author tracks in any GPX tool, for example the free gpx.studio editor, then upload the resulting file to your Media Library. Source code The front-end JavaScript in build/ is minified (the block editor script is not, so that its strings stay translatable). The human-readable source lives in the plugin's src/ directory, which is included in this plugin, and is also available with full build instructions at the public repository: https://github.com/SirLouen/gpx-route-map. The plugin is built with Vite (pnpm install && pnpm run build).

安装:

  1. Upload the gpx-route-map folder to /wp-content/plugins/, or install through the Plugins screen.
  2. Activate the plugin.
  3. Add the GPX Route Map block to a post or page and select a GPX file, or use the shortcode.

屏幕截图:

  • Selecting a GPX file in the block editor.

升级注意事项:

2.0.0 Breaking change: custom tile URLs are removed, which is why this is 2.0.0. Maps and shortcodes that used one now show the site's tile provider; choose OpenStreetMap, OpenTopoMap or a Thunderforest style for a single map instead. Also adds a live editor preview and an optional Min elevation. 1.8.0 Needs WordPress 6.8 or newer. Adds a site-wide maximum zoom setting, fixes waypoint popups that some themes made unreadable, and warns in the editor about a tile URL that will not work. Sites on 6.6 or 6.7 are not offered this update and keep the version they have. 1.7.0 Map height can now be set once for the whole site, with separate sizes for tablets and phones. Existing maps keep the size they already had. Uses MapLibre GL JS 6, which needs a browser with WebGL2. 1.6.1 Translation and wording fixes: the front-end "Map failed to load" message is now translatable, and an editor hint pointed at the old settings location. 1.6.0 Settings move to their own screen at Settings > GPX Route Map, and Thunderforest map tiles can now be used with an API key. 1.5.0 Adds a setting for choosing which figures the stats bar lists. 1.4.0 Adds a site-wide setting for showing or hiding the stats bar and the elevation profile. 1.3.0 Adds a metric/imperial unit setting. Existing maps keep showing metric until you change it. 1.2.1 Compatibility release for WordPress 7.1. 1.2.0 Adds a full Spanish translation and makes every remaining string translatable. 1.1.0 Statistics are now computed in the browser and stored with each block. Existing GPX blocks keep working; re-save one to refresh the statistics shown without JavaScript. 1.0.0 Initial release.

常见问题:

Does it require Advanced Custom Fields or any other plugin?

No. It has no plugin dependencies and works with core WordPress.

Where do the maps and elevation come from?

Map rendering uses MapLibre GL JS (BSD-3-Clause) with raster tiles from OpenStreetMap, OpenTopoMap or Thunderforest, as chosen under Settings > GPX Route Map or for a single map. The track, elevation profile and the distance/elevation stats are all computed from your GPX file in the browser. When you add the block, those stats are saved with it so the summary still shows without JavaScript.

Can I show miles and feet instead of kilometres and metres?

Yes. Go to Settings > GPX Route Map and set "Units" to Imperial, and every map on the site switches to miles and feet. A single map can use different units from the rest: pick them in the block's Display panel, or add units="imperial" to the shortcode. Switching is instant and can be undone at any time, because the plugin always stores distances and elevations in metric and only converts them for display.

Can I change how tall the maps are?

Yes, for the whole site or for a single map. Go to Settings > GPX Route Map and set "Map height" to size every map that does not set its own. To change just one map, turn off "Use site default height" in the block's Display panel and pick a height, or add height="600" to the shortcode. Heights run from 200 to 1200 pixels.

Can one map use different tiles from the rest?

Yes. In the block's Map tiles panel, pick a tile provider instead of "Site default". Thunderforest styles appear there once an API key is saved under Settings > GPX Route Map. The shortcode takes provider="opentopomap" and the like.

Visitors can zoom in past where my tiles stop

The map stops at the last zoom level its tile provider has tiles for. The plugin knows where OpenStreetMap, OpenTopoMap and Thunderforest stop; for a tile server of your own that stops early, say so with the gpxrm_tile_max_zoom filter. "Max zoom" under Settings > GPX Route Map is something else: how close a map opens when it frames a short route. A single map can differ: use the block's Max zoom slider, or add maxzoom="15" to the shortcode.

Can maps be shorter on phones?

Yes. Alongside the main height there are separate Tablet and Mobile heights, both site-wide and per map, and a shortcode accepts height_tablet and height_mobile. Tablet applies at 782px and below and Mobile at 480px and below, matching the widths WordPress itself uses. Leave one empty and the map follows the site's size for that screen, or the size above it when the site sets none - so a site-wide Mobile height applies to every map, including one given its own taller height. The elevation profile also gets shorter on phones so the map and the profile stay visible together.

Can I hide the stats bar or the elevation profile?

Yes, either one, for the whole site or for a single map. Go to Settings > GPX Route Map and set "Stats bar" or "Elevation profile" to Hidden to change every map at once. To change just one map, use the block's Display panel, or add stats="false" or elevation="false" to the shortcode. A map set to "Site default" follows the setting, so you can change your mind later in one place.

Can I show only some of the figures in the stats bar?

Yes. Under Settings > GPX Route Map, "Stats shown" has a checkbox for each of Distance, Elevation gain, Elevation loss, Max elevation, Min elevation and Waypoints, so you can keep just the ones you care about. Min elevation is off unless you tick it. A single map can differ: open the block's "Stats bar items" panel, turn off "Use site default" and tick what you want, or pass fields="distance,gain" to the shortcode. At least one figure always stays ticked; to remove the bar altogether use the separate "Stats bar" setting.

Can visitors download the GPX file?

Yes, if you switch the download button on. It is off by default. Go to Settings > GPX Route Map and set "Download button" to Shown, or turn it on for a single map from the block's Display panel or with download="true" on the shortcode. The button appears on the map next to the zoom and fullscreen controls. Files in your Media Library download with their own filename; a GPX hosted on another site opens instead of downloading, because browsers only honour the download hint for files served from the same site.

Can I show contour lines and hill shading?

Yes. Go to Settings > GPX Route Map and set the tile provider to OpenTopoMap. It needs no account. A single map can differ: pick it in the block's Map tiles panel, or add provider="opentopomap" to the shortcode. It is run by volunteers, with no guarantee that it stays available, and has less detail close in.

Can I use Thunderforest's outdoor and cycling maps?

Yes. Sign up at thunderforest.com, then go to Settings > GPX Route Map, set the tile provider to the Thunderforest style you want (Outdoors, OpenCycleMap, Landscape or Atlas) and paste your API key. With the key saved, a single map can use a different style: pick it in the block's Map tiles panel, or add provider="thunderforest-cycle" and the like to the shortcode. Their free plan covers 150,000 tiles a month, which is roughly 8,000 map views; busier sites need a paid plan. Two things worth knowing. The key appears in your pages' source, because visitors' browsers fetch the tiles, and Thunderforest cannot lock a key to one domain, so watch your usage. And the map credits both Thunderforest and OpenStreetMap automatically, which their terms require and do not allow you to remove.

Can I use my own map tiles?

Not from the editor: the block offers the providers above. A developer can point maps at another tile server with the gpxrm_tile_url filter, and say where its tiles stop with gpxrm_tile_max_zoom. Tile addresses set on a map before 2.0 are no longer used; those maps follow the site's provider.

Can I link a GPX file hosted on another site?

Only if that host allows cross-origin (CORS) requests, because the visitor's browser fetches the file directly, and most external sites don't send the required header. The front end then shows "Could not load GPX file: its host does not allow cross-origin (CORS) requests. Upload the file to this site instead." even though the link opens fine in a browser tab. Uploading the file to your Media Library is the reliable option.

Why don't my existing GPX files appear in the media picker?

GPX files uploaded before this plugin was activated may be stored with a generic XML type or no type at all. The picker shows GPX and XML types; files stored with an empty or unrelated type won't appear. Re-upload them to fix the stored type. On multisite, the network's "Upload file types" setting must also include gpx.

The front end says "Map failed to load." What's wrong?

The map library could not be downloaded. The plugin loads its map code as a native JavaScript module, which optimization plugins normally leave alone. But if yours is configured to combine, inline or relocate module scripts, exclude this plugin's view script from it. Visitors on a flaky connection can simply click the message to retry.

更新日志:

2.0.0 1.8.0 1.7.0 1.6.1 1.6.0 1.5.0 1.4.0 1.3.0 1.2.1 1.2.0 1.1.0 1.0.0