=== PeakMaps ===
Contributors: consigno
Tags: maps, leaflet, hiking, gpx, peaks
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.9.90
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Leaflet map with GPX tracks, markers, elevation profile, and its own filterable peak database with table and Gutenberg blocks.

== Description ==

Turn your list of summits, trails, and viewpoints into a beautiful, interactive map — no coding required.

PeakMaps is a WordPress plugin built for hiking blogs, outdoor clubs, tourism sites, and anyone who wants to showcase peaks, trails, and points of interest on a real, interactive map. Add a searchable database of locations, complete with GPX tracks and elevation profiles — then drop it into any page or post with a Gutenberg block or shortcode.

PeakMaps is **completely free**, with no peak-count cap, no expiring features, and no upgrade popups. **PeakMaps Pro** is a separate, optional add-on for sites that want Norwegian topographic maps (Kartverket), custom marker styles, extra data fields, on-map tools, GPX downloads, and bulk CSV import/export.

[See it in action: demo table](https://fjellturblogg.no/fjelltopper) | [demo map](https://fjellturblogg.no/kart)

= What PeakMaps does =

Add peaks to your own dedicated database, attach GPX tracks, and PeakMaps takes care of the rest: rendering them on interactive Leaflet maps, generating a sortable and filterable table, calculating elevation profiles — all without a single line of code. Place as many maps and tables as you like, anywhere on your site, each with its own filters and settings.

= 🗺️ Interactive map =

* Built on **Leaflet** — fast, lightweight, and mobile-friendly.
* **Marker clustering** keeps busy maps clean at lower zoom levels.
* Background layers: **OpenStreetMap** and **OpenTopoMap**, with an easy switcher for visitors.
* **Fullscreen mode** for an immersive map view.
* Smooth touch and pinch-zoom on mobile.

= 🏔️ GPX tracks and elevation profiles =

* Attach a GPX track to any peak and it renders on the map automatically — the map zooms to show the whole track.
* Map and profile work together: point at the track on the map to see that spot in the elevation profile, or click the profile to zoom the map there.
* Optional **distance markers and direction arrows** along the track, switched on and off by visitors with a «km» button on the map.
* **Elevation profile charts** with interactive hover tooltips — elevation and distance at any point along the track.
* Ascent/descent totals, min/max elevation, total distance calculated automatically, plus an optional **estimated walking time**.
* Optionally **coloured by steepness** (0–5 % up to 35 %+), with the gradient in the hover tooltip; **start and finish** are marked on the map.
* **Secure GPX proxy** built in — tracks hosted anywhere load smoothly without CORS issues.
* Each track's **length and total ascent are stored with the peak**, and the admin warns you when a GPX file can't be read or never comes near its peak (usually the wrong file).

= 📊 Smart, filterable table =

* Fully **sortable and searchable** — sort by name, elevation, track length, ascent, municipality, county, visited date, and more.
* **Live filtering** by municipality, county, elevation range, track length (e.g. hikes under 10 km), free-text search, and visited status — no page reload.
* **Pagination** with configurable results per page.
* Optional row-number column and configurable column selection per instance.

= 🗄️ Your own peak database =

* A dedicated, purpose-built database — not repurposed WordPress posts — for fast, clean querying at any scale, with no upper limit.
* **Visited/completed tracking** — doubles as a personal or club peak-bagging log.
* Show/hide individual peaks without deleting their data.
* Full admin interface: search, filter, sort, bulk-edit, bulk-delete, and duplicate entries.

= 🌍 Built for real-world use =

* Works via **Gutenberg blocks** (with live editor preview) or classic **shortcodes** (`[peakmaps_map]` and `[peakmaps_table]`).
* **Norwegian Bokmål translation** included; standard WordPress i18n for adding more languages.
* Automatic **cache clearing** on settings changes, compatible with WP Rocket, W3 Total Cache, WP Super Cache, LiteSpeed Cache, and WP-Optimize.
* Assets load only on pages that actually contain a map or table.

= PeakMaps Pro =

[PeakMaps Pro](https://consigno.no/peakmaps) is a separate, optional add-on that extends the free plugin without removing anything from it. Pro adds:

**🇳🇴 Norwegian Kartverket maps**
Norway's official topographic map, raster map, and nautical chart as additional background layers. When a Kartverket layer is active, Pro also refines elevation profiles against Kartverket's own terrain model for extra accuracy.

**🎨 Custom marker styles**
Choose from circular, square, triangular, diamond, or star markers in any colour — or upload your own custom marker image.

**📝 Five custom extra fields**
Add up to five fields with labels you choose — difficulty, parking notes, permit info, or anything your project needs. Supports wildcards (`*`, `?`), exclusion (`!`), and numeric comparisons (`>`, `<`, `>=`, `<=`) in filters.

**🛠️ On-map tools**
A distance-measuring tool and a «find my position» GPS button for visitors browsing on mobile.

**⬇️ GPX download**
Let visitors download GPX files, with an optional terms/consent dialog.

**📥 CSV import and export**
Bulk-load or update peaks from a spreadsheet, with insert mode (add new entries) and update mode (fill in missing fields on existing ones). Export your full peak database to CSV at any time — perfect for backups or editing in Excel.

[Find out more about PeakMaps Pro →](https://consigno.no/peakmaps)

= Perfect for =

* Hiking and outdoor blogs documenting summits, trails, and viewpoints
* Tourism boards and destination sites showcasing regional attractions
* Hiking clubs maintaining a shared, browsable peak list
* Personal peak-bagging logs for trackers working through a summit list

== Source Code ==

This plugin's own frontend script, `assets/js/nu_script.js`, is shipped as a whitespace-minified build for faster loading. Its full human-readable source — same code, same behavior, just formatted — is included in this plugin at `assets/src/nu_script.js`. No bundler, transpiler, or other build step is used beyond whitespace minification; regenerating the minified file from the source is a single pass through any standard JS minifier.

All other JavaScript and CSS files written for this plugin (everything under `assets/js/` and `assets/css/` not listed below) are already shipped in their normal, unminified, human-readable form — no separate source is needed for those.

Bundled third-party libraries (Leaflet, Leaflet.markercluster, Leaflet.fullscreen, Leaflet.UTM) are minified as distributed upstream; each file includes a header comment with its name, license, and source repository URL. GPXParser.js (MIT) is included in readable form with a few PeakMaps fixes, listed in its header comment.

== External services ==

PeakMaps connects to the following services. Nothing is sent to any of them unless a map is shown, or a peak with a GPX link is saved or recalculated.

**Map tiles — requested by the visitor's browser when a map is shown**

The browser asks the tile provider of the background map in use for the image tiles of the area in view. Each request carries only what any image request carries: the tile coordinates and zoom level, plus the browser's normal request data (IP address, user agent). No peak data, site content or personal data is sent.

* **OpenTopoMap** — the default background map, a topographic map built on OpenStreetMap data. Tiles from `tile.opentopomap.org`. [Usage policy](https://opentopomap.org/about) · [OpenStreetMap privacy policy](https://wiki.osmfoundation.org/wiki/Privacy_Policy) (OpenTopoMap does not publish a separate one)
* **OpenStreetMap** — the second background map in the layer switcher. Tiles from `tile.openstreetmap.org`. [Tile usage policy](https://operations.osmfoundation.org/policies/tiles/) · [Privacy policy](https://wiki.osmfoundation.org/wiki/Privacy_Policy)
* **Esri** (satellite, topographic) and **CARTO** (light, dark) — part of the plugin's layer list, but only shown when an add-on such as PeakMaps Pro switches them on. Tiles from `server.arcgisonline.com` and `basemaps.cartocdn.com`. Esri: [Terms of use](https://www.esri.com/en-us/legal/terms/full-master-agreement) · [Privacy policy](https://www.esri.com/en-us/privacy/overview). CARTO: [Terms of use](https://carto.com/legal/) · [Privacy policy](https://carto.com/privacy/)

**GPX files — requested by this site's server**

* *For the map:* GPX files hosted on another site are fetched through this site's own proxy, so the browser can draw them. The proxy only fetches URLs that exactly match a GPX link saved on a peak in this site's database.
* *For track statistics:* when a peak is saved, imported or recalculated, the server reads its GPX file (and the detailed «F» variant next to it, if there is one) to work out length, ascent, steepness and distance above 1000 m. A file on this site is read straight from disk; a file elsewhere is requested from the address given in the peak's GPX link.

Which third party, if any, receives a GPX request depends only on where the site owner hosts the files; the plugin's author runs no server involved in any of this.

== Installation ==

1. Upload the `peakmaps` folder to `/wp-content/plugins/`, or install the ZIP via Plugins > Add New > Upload Plugin.
2. Activate the plugin from the Plugins menu in WordPress.
3. Go to PeakMaps in the admin menu to set up map defaults and add peaks.
4. Add a map or table with the "PeakMaps" Gutenberg blocks, or the shortcodes `[peakmaps_map]` / `[peakmaps_table]`.

== Frequently Asked Questions ==

= How do I add peaks? =
Use the "New peak" button under the PeakMaps menu to add peaks one at a time — name, position, GPX track, and the other details.

= How do I display the map or table? =
Use the Gutenberg blocks, or the shortcodes `[peakmaps_map]` and `[peakmaps_table]`. Parameters are documented on the Help page in admin.

= The plugin uses a caching plugin — why don't my changes show up? =
The page cache may serve old HTML. PeakMaps clears the cache automatically when you save the map settings, but also remember to hard-refresh your browser.

= Do I have to pay to use PeakMaps? =
No. PeakMaps is completely free, with no locked features, limits, or license requirements.

== Screenshots ==

1. Interactive map with markers and elevation profile.
2. Sortable and filterable peak table.
3. Admin: map settings.

== Changelog ==

= 2.9.90 =
* The settings page is divided into tabs — General, Map, Background maps and Below the map — instead of one long page. All tabs are saved together, the page comes back on the same tab after saving, and a "Settings saved" notice now shows. Add-ons can add their own tabs (`peakmaps_settings_tabs` filter, `peakmaps_settings_tab_{id}` action); sections from older add-ons appear on a "More" tab.
* The elevation graph colour moved to "Below the map", next to the elevation profile.
* Shortcode help: the settings overview describes the tabs.

= 2.9.89 =
* New filter for add-ons: `peakmaps_gpx_stats_store` lets an add-on store its own figures (in its own columns) worked out from the same elevation profile as the peak's ascent and steepness. PeakMaps Pro uses it to describe how steep a hike is in its difficulty box.

= 2.9.88 =
* New filters for add-ons: `peakmaps_gpx_stats_profile` lets an add-on replace the heights the stored ascent, steepness and high-mountain distance are worked out from (PeakMaps Pro uses it so these numbers match its Kartverket-calibrated elevation profile), and `peakmaps_gpx_stats_key_extra` marks the stored numbers as out of date when such a setting changes.

= 2.9.87 =
* Saving the settings (or changing peaks) now also empties the page cache of SiteGround Speed Optimizer, WP Fastest Cache, Cache Enabler, Breeze, Hummingbird, Nginx Helper, Comet Cache, WP Engine and Super Page Cache for Cloudflare — besides WP-Optimize, WP Rocket, W3 Total Cache, WP Super Cache and LiteSpeed. Their separate copies for phones are emptied too, so a changed setting (e.g. which figures show above the elevation profile) no longer lingers on mobile.

= 2.9.86 =
* Peaks list: the "Show N peaks" choice is remembered in the browser again (the code for it was there but never called).
* The GPX proxy now uses wp_safe_remote_get(), so it can never reach addresses on the server's own network, and is capped at the same file size as the track statistics.
* The map no longer requests "trackFF.gpx" when a peak's GPX link already points to an «F» file.
* readme: one "External services" section, now also describing the server reading GPX files for track statistics.
* Housekeeping: unused CSS and translations removed; the settings page mentions the Pro download link as text instead of a disabled checkbox.

= 2.9.85 =
* Track statistics (length, ascent, steepness, distance above 1000 m) are now always worked out from the detailed «F» variant of the GPX file when there is one (aksla.gpx → akslaF.gpx), also when the map shows the light file. A missing or unreadable F file falls back to the normal one. All peaks are recalculated automatically the next time the peaks list is opened; an F file added later is picked up by the "Recalculate length and ascent" bulk action.

= 2.9.84 =
* Track statistics now include how far the track runs above 1000 m (filter `peakmaps_gpx_high_altitude`). Existing peaks are recalculated automatically the next time the peaks list is opened. Used by PeakMaps Pro's difficulty remarks for high-mountain terrain.

= 2.9.83 =
* New settings section "Below the map": the elevation profile, its steepness colours, and each figure on the line above it — lowest and highest point, total ascent and descent, length and walking time — can be switched on and off one by one. With all of them off, the line is hidden. Existing sites keep showing what they showed before.

= 2.9.82 =
* Distance markers, direction arrows and the «km» button are only shown on maps with a single GPX track. Overview maps with many tracks no longer show them for the centre peak's track, also when a visitor has switched them on elsewhere.

= 2.9.81 =
* Elevation profile: on a narrow screen the figures above the chart (height, ascent, length, walking time) wrap onto a second line instead of being cut off.

= 2.9.80 =
* Track statistics now include steepness: the steepest 200 m of the track (up or down), worked out from the GPX file together with length and ascent. Existing peaks are recalculated automatically the next time the peaks list is opened. Used by PeakMaps Pro's difficulty grade.
* Peaks list: a table with many columns now scrolls sideways instead of running off the page.
* For add-ons: fields an add-on adds to the peak form with a `data-pm-field` attribute are loaded and saved automatically.
