=== Route Maps ===
Contributors: racerpacer
Tags: map, block, gpx, directions, openstreetmap
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 0.1.3
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A map block for any page: your own places, GPX lines, a choice of looks and a Directions link for each place. No key and no account.

== Description ==

Route Maps adds one block, **Map**, and it works on any site and in any theme.

* **Places.** Add as many as you like. Click the small map in the block's settings to drop one, drag it to the exact spot, or type a name and press Find on map. Each place has a name and an optional note.
* **Lines.** Add up to six GPX files and each is drawn as a line: a route, a course, a walk. A GPX is cleaned when it is uploaded: times, heart rate and the name of whoever recorded it are taken out.
* **Looks.** Five map styles, from full colour to near black, and your own colour for the marks and the line. Set a look for the whole site under Settings, Maps, and change it on any one block.
* **Under the map.** The places are listed with a Directions link each. Number them, or leave them as plain pins.
* **Elevation profile.** Switch it on and each GPX line gets its distance, climb and a profile of its heights under the map.
* **Download the GPX.** Switch it on for a map with a GPX line and a button under the map lets people save the file, for their watch or phone.
* **On the page or in a popup.** A map can sit behind a button and open in a popup.
* **Light on the page.** The map library loads only when a visitor scrolls to a map, opens its popup, or presses Show the map on a block set to wait.
* **The editor's own controls.** Colour, spacing, border, corner radius, shadow and text size all work on the block.

A shortcode draws the same thing in the classic editor or a page builder:

`[rpmap_map points="54.4609,-3.0886,Village hall|54.4802,-3.1104,Lay-by" gpx="123" look="positron" height="360"]`

For one place, `[rpmap_map lat="54.4609" lng="-3.0886" name="Village hall"]` does. Other settings: `title`, `colour`, `zoom`, `display="popup"`, `button`, `numbered`, `list`, `directions`, `click`, `profile` and `download`, each `yes` or `no` where it is a switch.

**With the RacerPacer plugin.** Route Maps draws the location maps and the GPX routes for club runs and events in the RacerPacer plugin. That plugin works without this one, showing an address and a Get directions link in place of each map.

**For developers.** `\RacerPacer_Maps\map_box_html()` returns a map alone, for your own layout, and `\RacerPacer_Maps\map_html()` returns the whole component. `\RacerPacer_Maps\enqueue_pin_picker()` puts Find on map and a click-and-drag map after any pair of latitude and longitude inputs on an edit screen. `\RacerPacer_Maps\summarise_gpx()` reads a GPX file into its line, distance, climb and elevation profile. The colours are four CSS variables: `--rpmap-accent`, `--rpmap-on-accent`, `--rpmap-line` and `--rpmap-radius`.

== Installation ==

1. Upload the `racerpacer-maps` folder to `/wp-content/plugins/` and activate it.
2. Go to Settings, Maps to choose the look every map starts with.
3. Edit a page, add the **Map** block and add your places in the block's settings.

== Frequently Asked Questions ==

= Do I need an API key or an account? =

No. The maps are drawn from OpenFreeMap, which asks for neither.

= Can I use my own map style? =

Yes. Under Settings, Maps choose "My own style" and give the https address of a MapLibre style.

= Can I stop the map loading until a visitor asks for it? =

Yes. Switch on "Wait for a press before loading the map" on the block, or show the map in a popup.

= What happens to my maps if I delete the plugin? =

The Map blocks stay in your pages and show nothing until the plugin is back. Deleting it removes its setting and what it worked out about your GPX files. The GPX files themselves stay in the media library.

== External services ==

New versions come from builtby.racerpacer.com (https://builtby.racerpacer.com), since the plugin isn't on WordPress.org.

* What is sent and when: when WordPress checks for updates (about twice a day, and when you press Check again under Dashboard, Updates), your server asks `builtby.racerpacer.com` for the latest version. The request carries the plugin's version number and your server's IP address, and nothing else: not your site's address, settings or content. builtby counts the checks for each version and doesn't keep the IP address. When you update, the new zip downloads from the same place.
* Switching it off: add `define( 'RACERPACER_NO_UPDATE_CHECK', true );` to wp-config.php. You can still update by uploading a new zip.
* builtby privacy policy: https://builtby.racerpacer.com/privacy/

This plugin loads map tiles from OpenFreeMap (https://openfreemap.org) to draw a map.

* What is sent and when: when a visitor scrolls to a map, opens a map's popup or presses Show the map, their browser requests the map style and tiles from `tiles.openfreemap.org`. As with any web request, that includes their IP address and the part of the map being viewed. A page with no map sends nothing, and nothing is sent by your server. The same tiles load in wp-admin when an editor opens a Map block's settings or presses Set the pin on a map.
* Switching it off: a map set to wait for a press, or shown in a popup, sends nothing until it is pressed. Under Settings, Maps you can point every map at a MapLibre style of your own, and the requests go there.
* OpenFreeMap terms of service: https://openfreemap.org/tos/
* OpenFreeMap privacy policy: https://openfreemap.org/privacy/

The **Find on map** button looks a place up on OpenStreetMap Nominatim (https://nominatim.openstreetmap.org).

* What is sent and when: only when an editor presses that button, your server sends the name typed for the place to `nominatim.openstreetmap.org`, with your site's address in the request's User-Agent as that service asks. The answer is kept for a week. Visitors' browsers are never involved.
* Switching it off: Settings, Maps, Find on map. The `racerpacer_maps_geocode_enabled` filter does the same.
* Nominatim usage policy: https://operations.osmfoundation.org/policies/nominatim/
* OpenStreetMap Foundation privacy policy: https://osmfoundation.org/wiki/Privacy_Policy

The **Directions** link is a link to Google Maps (https://www.google.com/maps) carrying the place's latitude and longitude. Nothing is sent to Google unless a visitor follows it. The `racerpacer_maps_directions_url` filter points it elsewhere.

* Google Maps terms: https://www.google.com/help/terms_maps/
* Google privacy policy: https://policies.google.com/privacy

== Resources ==

* MapLibre GL JS, Copyright MapLibre contributors. License: BSD 3-Clause. Licence text: assets/js/vendor/LICENSE-maplibre.txt

== Changelog ==

= 0.1.3 =
* Renamed Route Maps (it was RacerPacer Maps). The folder, the block, the shortcode and your settings are the same.
* A map with a GPX line can show a Download the GPX button under it: a switch in the block's GPX lines settings, or `download="yes"` on the shortcode. Off unless you switch it on.
* A map with a GPX line can show each line's distance, climb and elevation profile under it: a switch in the same settings, or `profile="yes"`. Also off unless you switch it on.
* In the block's GPX lines settings each file is listed by its name rather than its number.

= 0.1.2 =
* Offers new versions under Dashboard, Updates, from builtby.racerpacer.com. See External services for what the check sends and how to switch it off.

= 0.1.1 =
* A map is a labelled region rather than a picture, since it holds buttons once drawn, and its markers have a role and the place's name.
* A map waits until the page has loaded and is at least a fifth on screen before fetching the map library.
* The map credit is easier to read.

= 0.1.0 =
* First version. The Map block and the `[rpmap_map]` shortcode: places, GPX lines, five looks, a Directions link for each place, on the page or in a popup.
* Takes over the maps, the place search, the pin picker and the GPX reading that were inside the RacerPacer plugin up to its version 0.5.0.
