minad / osm

:earth_africa: osm.el - OpenStreetMap viewer for Emacs
GNU General Public License v3.0
520 stars 14 forks source link

+title: osm.el - OpenStreetMap viewer for Emacs

+author: Daniel Mendler

+language: en

+export_file_name: osm.texi

+texinfo_dir_category: Emacs misc features

+texinfo_dir_title: Osm: (osm).

+texinfo_dir_desc: OpenStreetMap viewer for Emacs

+html: GNU Emacs

+html: GNU ELPA

+html: GNU-devel ELPA

+html: MELPA

+html: MELPA Stable

+html:

The map data is © OpenStreetMap contributors, licensed under the ODbL The map rendering is © OpenTopoMap, licensed under the CC-BY-SA.

Osm.el is a tile-based map viewer, with a responsive movable and zoomable display. The map can be controlled with the keyboard or with the mouse. The viewer fetches the map tiles in parallel from tile servers via the =curl= program. The package comes with a list of multiple preconfigured tile servers. You can bookmark your favorite locations using regular Emacs bookmarks or create links from Org files to locations. Furthermore the package provides commands to search for locations by name and to open and display GPX tracks.

+toc: headlines 8

The package is available on GNU ELPA and can be installed with =package-install=. Note that Osm.el requires Emacs 28 and depends on the external =curl= program. Emacs must be built with =libxml=, =libjansson=, =librsvg=, =libjpeg= and =libpng= support. The following is an example configuration which relies on =use-package=. Please take a look at the [[https://github.com/minad/osm/wiki][wiki]] for additional configuration.

+begin_src emacs-lisp

(use-package osm :bind ("C-c m" . osm-prefix-map) ;; Alternatives: osm-home' orosm'

:custom ;; Take a look at the customization group `osm' for more options. (osm-server 'default) ;; Configure the tile server (osm-copyright t) ;; Display the copyright information

:config

;; Add custom servers, see also https://github.com/minad/osm/wiki ;; (osm-add-server 'myserver ;; :name "My tile server" ;; :group "Custom" ;; :description "Tiles based on aerial images" ;; :url "https://myserver/tiles/%z/%x/%y.png?apikey=%k") )

+end_src

There exist multiple methods to store a location, such that you can return there afterwards.

Bookmarks and Org links can be created at point by clicking with the mouse. See the docstrings of the commands ~osm-bookmark-set~ and ~org-link-store~.

**** Org link examples

Click on a link or press ~RET~ to jump to the location. These links work in Org buffers in Emacs. Furthermore you can open Org links in arbitrary buffers with ~org-open-at-point-global~. I recommend binding the command to a convenient key, e.g., ~C-c o~. The format of the links complies with the [[https://en.wikipedia.org/wiki/Geo_URI_scheme][geo URI scheme]] defined by [[https://datatracker.ietf.org/doc/html/rfc5870][RFC 5870]].

+begin_example

[[geo:41.869560826994544,12.45849609375;z=6;s=opentopomap][Italia, 41.87° 12.46° OpenTopoMap]] [[geo:51.48950698022105,-0.144195556640625;z=11][London, England, 51.49° -0.14°]] [[geo:55.686875255964424,12.569732666015625;z=12;s=cyclosm][København, Danmark, 55.69° 12.57° CyclOSM]] [[geo:27.961656050984658,86.89224243164062;z=13;s=opentopomap][Mount Everest, 27.96° 86.89° OpenTopoMap]] <geo:Tour Eiffel, Av. Gustave Eiffel, Paris> (Address link)

+end_example

**** Elisp link examples

Place the point behind the closing parenthesis and press ~C-x C-e~ to jump to the location. The Elisp links can be used in arbitrary text files. Since they are Elisp s-expressions they can be easily manipulated programatically.

+begin_src emacs-lisp

(osm 41.869561 12.458496 6 'opentopomap "Lazio, Italia") (osm 51.489507 -0.144196 11 "London, Greater London, England, SW1A 2DX, United Kingdom") (osm 55.686875 12.569733 12 'cyclosm "København, Københavns Kommune, Region Hovedstaden, 1357, Danmark") (osm 27.961656 86.892242 13 'opentopomap "Khumjung, Khumbupasanglahmu, सोलुखुम्बु, Province #1, Nepal") (osm "Tour Eiffel, Av. Gustave Eiffel, Paris") ;; Address link

+end_src

Osm provides a simple distance measurement utility. In order to measure a distance, place or select a pin by clicking with the left mouse button. Then create one or more additional way points by pressing shift and clicking the left mouse button. The length of the track will be shown in the echo area. You can select the way points of the track and delete them with ~d~ or ~DEL~.

Top-level commands in =osm-prefix-map=. These bindings are available globally if you bind =osm-prefix-map= to a key like =C-c m=. For example, to search for a location press the key sequence =C-c m s=. Furthermore the key bindings are available in Osm buffers. There it is sufficient to press the key =s= only to initiate a search.

Some additional key bindings are available in Osm buffers:

There have been other attempts at map viewers in Emacs before.

Since this package is part of [[https://elpa.gnu.org/packages/osm.html][GNU ELPA]] contributions require a copyright assignment to the FSF.