Using the reference site
How to choose a language, find the source code, search, save the map, read the layer key, turn layers off and draw on the reference site, and how each works from the keyboard and a pointer. It also shows a developer what a host built on the SDK offers.
The pages
The site has three pages. / is the product page: what the SDK is, a picture of the playground at work, what you get, when it fits and when it does not, the licence and its cost, how ready it is, the part of the code that mounts the map and the questions developers ask first. It is server-rendered, in British English only, and loads no map code. It describes the SDK's design, not counts or plans; the latest version and its date are read from CHANGELOG.md when the site is built, so a release changes them without an edit. Change its words in packages/web/src/product/productContent.ts when what the SDK is, who it is for or what it lacks changes. /map is the playground, the map this guide describes. /privacy is the privacy policy.
The playground was at / until the product page took its place. A link shared before then keeps the map's state after # (/#map=11.00/-33.92000/18.42000), which the server never sees, so the product page reads it in the browser before it paints and, when the part after # holds map state, opens /map with the same state instead. A plain / and the page's own anchors (/#questions) stay on the product page. From the playground, Help's About block has a link back to the product page.
For search engines and language models the site serves sitemap.xml, robots.txt, llms.txt (product first, playground second), llms-full.txt (that file with the product page's whole text) and index.md (the product page as Markdown), all built from the pages' own content. llms.txt links the documentation site's own llms.txt (at https://docs.mapcairn.com/llms.txt), which indexes the documentation's full text in files split by area, and does not repeat any of it, and robots.txt names the documentation site's sitemap as well, because a crawler reads only the root file. Every documentation page is also a plain Markdown file next to it (/index.md on the documentation site), linked from the page's head.
Search by place name or coordinates
As you type, the search box suggests places once you pause after three or more characters. Choose one with the arrow keys and Enter, or tap it, and the map goes straight to it. A search by Enter or the Search button that finds exactly one place goes straight to it too, with no list to choose from; several places open the list. If you have moved to another control before the answer arrives, the list opens instead. The suggestions come from the Photon service, so the text you have typed so far is sent there as you type; the privacy page says so. A screen reader hears how many suggestions there are. If the service is unavailable, the box says so once and stops suggesting for a while.
The search box finds a place by name through the geocoder when you press Enter or the Search button, with or without a suggestion highlighted, and that works when suggestions do not. It also takes a pair of coordinates, and answers that one itself, in the browser, with no request to the geocoder: one place named "Coordinates 26.20410° S, 28.04730° E", which the map goes to at once, as it does for any search that finds exactly one place (the box shows the name and a screen reader hears "Showing Coordinates 26.20410° S, 28.04730° E on the map."). It reads:
- decimal degrees, latitude first:
-26.2041, 28.0473or-26.2041 28.0473. Every value needs a decimal point with digits after it, or a degree sign or the word degrees - hemisphere letters (or the words north, south, east and west) before or after a value, in either order:
26.2041S 28.0473E,S26.2041 E28.0473,28.0473 E, 26.2041 S - degrees, minutes and seconds with the usual symbols or words:
26°12'14.8"S 28°02'50.3"E,26 degrees 12 minutes 14.8 seconds south, 28 degrees 2 minutes 50.3 seconds east
In Afrikaans the words are read too (noord, suid, oos, wes, graad, minuut, sekonde, and the letter O for east), for example 26.2041 grade suid, 28.0473 graad oos. Digits of any script (Arabic-Indic, Devanagari, Bengali, full-width and the rest of the Unicode decimal digits), the Unicode minus sign and other dashes, the Arabic comma, semicolon and decimal separator, full-width punctuation and the bidirectional marks that text pasted from a right-to-left page carries are read as their ASCII forms, so ٢٦٫٢ ٢٨٫٠ and 26.2 28.0 are the pair 26.2 28.0. A thousands separator is read as white space, because no coordinate has a digit group. A comma is a decimal mark in two layouts only, and only when the text has no decimal point: the values are separated by a semicolon (26,2041; 28,0473), or by white space with a comma in every number and no other comma in the text (26,2041 28,0473). A comma between digits is never a thousands separator, so 26,28 and 1,234 on their own are place names; 26,5 28.3 (mixed marks), 26,5, 28,3 (commas that could be either) and 26.5,28 (a comma next to a point is a separator, and the second value is a bare number) are not coordinates. Degrees and minutes with a decimal-comma minute need a semicolon: 26°30,5' S; 28°3,3' E is read, 26°30,5' S 28°3,3' E is not, because not every number has a comma. A negative sign (hyphen, a dash or Unicode minus) cannot be mixed with a hemisphere letter. A bare whole number is not a coordinate, so 12 34, 3 4, +27 82 and E1 6 are searched as place names; so are 02-123 and 12-14, because a minus sign that touches a number before it is not the start of a negative value. Text that is out of range (latitude beyond 90, longitude beyond 180), a lone number such as a postcode, or anything with extra text is treated as a place name and searched as usual. Showing a coordinate result sends nothing to the geocoder, but the map loads tiles for that area as it does for any move. The parser is parseCoordinates in @mapcairn/core, and useSearch uses it, so the Directions panel's place search reads coordinates too.
Choose a language
The site speaks English (British) and Afrikaans. Settings has a Language control with Automatic, English and Afrikaans, each language named in its own language. Automatic, the default, follows the browser: Afrikaans when the browser lists Afrikaans (af or af-ZA) before any kind of English, English otherwise. The choice is kept on the device with the other settings and is never put in a shared link.
The page renders in English and switches as soon as the app starts, so a visitor who chose Afrikaans can see English for a moment on a first load; the page's lang is set from the stored choice before the page paints, then follows the language in use. Afrikaans is loaded only when it is chosen. The error page ("Page not found", "Something went wrong") follows the same choice, and Automatic follows the browser. Because the server cannot read the device's stored choice, an error page also arrives in English and switches once the page has started; if Afrikaans cannot be loaded it stays in English. In Afrikaans the coordinates name east with O (oos), and the search box reads O as well as E. The privacy page follows the language, and so does the title in the browser tab once the page has loaded; the page's description for search engines and link previews stays English, and so do the credits. The notes in Settings, Directions and the pin card that say what each service receives are translated too. Only what shows in the app is translated: PRIVACY.md and the other documents in the repository are English only, and the developer design guide, which is built only in development and test builds, is English.
Find the source code and licence
The site is open source software under the AGPL-3.0. Open Settings and scroll to the end of Help: the About block says so and has two links: "About MapCairn, the SDK behind this map", which opens the product page at / in the same tab, and "View the source code and licence on GitHub", to the public repository. The GitHub link opens in a new tab, and nothing is requested from GitHub until you follow it. The privacy policy link is in Settings above Help, and the map's credits button, at the bottom of the map, lists the credits and ends with an "About MapCairn" link to the product page. On a first visit the credits wait while the welcome card or the tour is on screen, and show themselves when you answer it, zoom, move the map or after thirty seconds. The block is the reference site's own; an SDK host passes its own text and link, or none, as the about prop of SheetContent, described in Extend the SDK.
Save an image and choose between features
The sheet's "Save image" button saves a PNG of the map with its layers, any drawn shapes and credits, made in the browser from what the map has already loaded. A tap that finds several features opens a list, and the I key opens the same list for the centre of the map. Neither needs configuration.
Read the key on the map
While a layer that has a key is on, its key shows on the map, above the scale bar, so you can read what its colours and shapes mean without opening Layers. Each layer has a block: its name, then one line for each colour or shape with its words. A layer with no key, such as the imagery layers, has no block, and with no keyed layer on there is no key at all.
A phone, held either way up, starts the key as a small chip, "Key, 3 layers", with the symbols of a few of the layers; a tablet or a desktop starts it open. That is decided when the key first appears, so turning the phone does not change it. Choose the chevron to shrink the key to the chip, and the chip to open it again; the button is named "Key, 3 layers" either way. The key remembers your choice until you reload the page; it is not stored between visits and puts nothing in the address. When many layers are on, the key scrolls inside its own height. It steps aside while the map credits are open, and when something else leaves too little room above the scale bar.
Turn layers off
In the Layers section, "Turn off all layers" at the top turns every layer off at once, and shows how many are on ("3 on"); it is greyed out when none is. Each group heading has the same action for its own layers, such as "Turn off 2 in Fires", while any of them is on. There is no confirmation. Below the button, "Turned off 3 layers." appears with an Undo, which turns those layers back on; their settings stay as they were, because a layer keeps its settings while it is off. A layer you turn on again yourself leaves the Undo, and the count drops. The Undo stays for ten seconds, and waits while a mouse is over it or it has keyboard focus. There is no "turn on all", because each layer you turn on asks its provider for data.
Draw and export shapes
Choose Draw shapes in the control group beside the map. Pick Point, Line, Polygon or Circle, then tap the map to place points, or use Add point at map centre (or Space) after panning. A circle takes its centre first and its radius from the second tap. Finish (or Enter) closes the shape; a polygon needs three points and no crossing edges. Tap a shape's edge or choose it in the Shapes list to edit it: drag a point, drag a small midpoint handle to add one, or select a point with Previous point and Next point and move it with the arrow keys. Undo and Redo cover every edit.
Shapes and export opens the list. Download GeoJSON, Download CSV and Download WKT build a file on your device from the finished shapes (the CSV has id, type, area_m2, length_m, the GeoJSON geometry as text, and then radius_m, centre_lng and centre_lat, the last three filled for a circle; these three columns were added at the end, and a CSV from before them still imports, with a circle as its polygon, as does a circle row whose radius is not above zero). The WKT file has one geometry to a line, longitude first, with a circle written as its polygon. Positions are written to six decimals, about 10 cm, and to more (up to ten) for a shape small enough that six would fold it in on itself; a circle that small also keeps its centre and radius exactly, where a larger one writes them to six and two decimals. A very small number is written out in full (0.00000078), never with an exponent such as 7.8e-7, so that readers of WKT and CSV that do not accept one can read the files. A link made with Copy link with shapes keeps positions to five decimals and a circle's radius to whole metres, so it is coarser than the files. A shape too small for that, such as a circle under a metre or a very short line, is left out of the link, and the message after the copy says how many were left out and suggests a file for them; if every shape is too small, nothing is copied. Import GeoJSON, CSV or WKT reads a file on your device, nothing is uploaded, and adds its points, lines, polygons and circles to the shapes as one undo step, then fits the map to them. It reads GeoJSON (a collection, a feature or a geometry, with Multi geometries split into one shape each and a polygon's holes left out), the CSV the export writes, so an exported file comes back as the same shapes, and WKT (one geometry or several, a line each or any layout, longitude then latitude, or the cells of a CSV column headed wkt in a comma-delimited file). WKT is read longitude first unless you pick Latitude, longitude in the WKT coordinate order menu above the import button; the choice is kept until you close or reload the page. If the first position of a file lies outside the world read one way but inside it the other way, nothing is imported, the result says so, and a button reads the file the other way. A file whose first position fits both ways, such as one in southern Africa, is read as chosen, so pick the order for such a file yourself. An EWKT prefix of SRID=4326;, as database exports write, is read and dropped. A geometry with any other SRID is skipped, and the result counts it as "in a coordinate system other than SRID 4326". A WKT geometry the importer cannot use is skipped and the rest of the file is still read: one with a measure (M, ZM), a curved type or another SRID is skipped on its own, to the bracket that closes it, even when it runs over several lines, so the geometries after it are kept; text that cannot be read is skipped up to the next line that starts a geometry (or an SRID= prefix) and counts as one. Each skip is counted in the result, and a file in which not one geometry can be used is refused with the reader's own words for the first fault in the message, and its position where it has one. A CSV cell is read the same way. A file of more than 1 MB, 500 shapes or 10,000 points is refused, and so is an import that would take the drawing past 1,000 shapes, and a shape with crossing edges, too few points or a position outside the world is skipped; the result says which and how many. Shapes are not stored and are not in the address bar. Copy link with shapes copies a link that carries them in a compact encoding of up to 2,000 characters; anyone who opens it sees the shapes, and moving the map in their window drops them from the address. In code, the pure rules are in packages/core/src/draw, the state hook is useDraw, the toolbar and overlay are DrawToolbar and DrawOverlay in @mapcairn/map, the import is parseShapeFile in core with the FileOpener port, and a host adds drawing by passing onDraw to EndStack and draw to SheetContent.