bdon.org map stuff https://bdon.org 00588F https://bdon.org/css/logo.svg Getting to the bottom of web map performance bdon.org <p>In 1993, two landmark PC games were released within months of each other: <a href="https://en.wikipedia.org/wiki/Doom_(1993_video_game)">id Software’s Doom</a>, and <a href="https://en.wikipedia.org/wiki/Myst">Cyan World’s Myst</a>. Doom is a fast-paced action game viewed from a first-person perspective, with detailed weapons, demons and gore; Myst is a point-and-click puzzle adventure on a creepy island.</p> <p>Doom was famously implemented using computer science techniques novel for games, such as <a href="https://en.wikipedia.org/wiki/Binary_space_partitioning">binary space partitioning</a> to determine the visibility of objects. In contrast, Myst was technically unsophisticated - with a first version created in <a href="https://en.wikipedia.org/wiki/HyperCard">HyperCard</a> - but was still lauded for having “photorealistic” graphics that demanded an entire compact disc of data.</p> <p>The core reason for Myst’s graphical fidelity is obvious to the millions that have seen both games: The visuals of Doom animate smoothly every few milliseconds, while the visuals of Myst are pre-rendered images that only change when the player clicks. In other words, Doom was a game with <em>real-time rendering</em>, which demanded orders of magnitude more computation and development effort than Myst.</p> <div class="image-part"> <div class="w-50"> <h5>Click Navigation in Myst</h5> <p>A slideshow of images, with a tiny cross-fade transition, gives the illusion of moving around the Myst island. The choppiness of this experience did not stop Myst from being a compelling game.</p> <p>source: Cyan</p> </div> <div class="w-50"> <video src="/images/web-map-performance/myst.mp4#t=0.001" controls="" /> </div> </div> <div class="image-part"> <div class="w-50"> <h5>Camera movement in Doom</h5> <p> Doom's smooth camera movement is a hard requirement for aiming and shooting at space demons; Doom's engine, <a href="https://en.wikipedia.org/wiki/Id_Tech">id Tech 1</a>, was re-used for other first person games like <a href="https://en.wikipedia.org/wiki/Chex_Quest" class="light-silver">Chex Quest</a>. </p> <p>source: id software</p> </div> <div class="w-50"> <video src="/images/web-map-performance/doom.mp4#t=0.001" controls="" /> </div> </div> <h2 id="1993s-pc-gaming-techniques-today">1993’s PC gaming techniques today</h2> <p>30 years later, the core difference between Myst and Doom’s graphics reveals itself again via a more universal computing experience: digital maps on the web.</p> <p>There are effectively two strategies to implementing interactive, zoomable maps in 2021. These are often referred to as <strong>raster maps</strong> and <strong>vector maps</strong>, but these names mostly describe the networking parts of a map system, and hide a spectrum of possible compromise designs. The key distinction is <strong>where rasterization - the conversion of shapes to pixels - happens.</strong> Unless you are using a <a href="https://en.wikipedia.org/wiki/Vector_monitor">vector monitor</a>, you are seeing raster images on your display right now, but this might have happened on your device CPU, GPU or even on a <em>totally different computer.</em></p> <div class="image-part"> <div class="w-50"> <h5>Vector rendering</h5> <p> A true vector graphics application: Asteroids implemented on an oscillograph. Unless you are using one of these, rasterization is happening somewhere. </p> <p>source: <a href="https://commons.wikimedia.org/wiki/File:Space_Rocks_(game).jpg" class="light-silver">Autopilot / Wikimedia</a></p> </div> <div class="w-50"> <img src="/images/web-map-performance/space_rocks.jpg" /> </div> </div> <div class="image-part"> <div class="w-50"> <h5>Modern Graphics Processing Unit (GPU) rendering</h5> <p> Vector features exist as arrays of vertices in GPU memory; these are rasterized to pixels efficiently by programmable shaders. Rasterization happens as late as possible, in parallel, without interacting with the CPU. </p> <p>source: <a href="https://learnopengl.com/Getting-started/Hello-Triangle">Learn OpenGL</a></p> </div> <div class="w-50"> <img src="/images/web-map-performance/openGL_pipeline.png" /> </div> </div> <h2 id="the-myst-approach-to-map-rendering">The “Myst” approach to map rendering</h2> <p>So-called <em>raster maps</em> are best embodied by <a href="https://leafletjs.com">Leaflet</a>, an extremely popular library for displaying zoomable, pannable maps with geographic overlays. The typical flow from geodata to pixels with a Leaflet map goes something like this:</p> <ul> <li>Map data exists in vector form, in a format like GeoJSON, ESRI Shapefile, or PostGIS tables.</li> <li>At some point - either on-demand or preprocessed - this data is rasterized into image tiles via a program like <a href="https://mapserver.org">MapServer</a> or <a href="https://mapnik.org">Mapnik</a>. Images can be PNGs, JPGs, whatever - they are all the same size, and correspond to regions of Earth based on the <a href="https://en.wikipedia.org/wiki/Web_Mercator_projection">Web Mercator projection.</a>.</li> <li>The map tiles are displayed in a web browser via <code class="language-plaintext highlighter-rouge">img</code> tags. Since images are everywhere on the web, browsers are designed to be very efficient at fetching images off-thread and animating them with GPU acceleration.</li> </ul> <p>Some free or commercial services offer pre-rendered image tiles directly, like the default rendering of OpenStreetMap data on <a href="">openstreetmap.org</a>https://www.openstreetmap.org/, creative cartographic styles by <a href="http://maps.stamen.com">Stamen Design</a>, basemap tiles for visualization by <a href="https://carto.com/basemaps/">CARTO</a>, or <a href="https://maps.wikimedia.org">Wikimedia maps</a> embedded on Wikipedia. APIs may offer hi-DPI image tiles for Retina displays; the general conventions around these image map tiles are encoded in standards like <a href="https://www.ogc.org/standards/wmts">WMTS</a> and can be consumed by other libraries like <a href="https://openlayers.org">OpenLayers</a> or <a href="https://pigeon-maps.js.org">Pigeon Maps</a>, a React-centric library.</p> <p>The crucial compromise of this approach is <strong>tiles only exist at discrete zoom levels with no intermediate states.</strong> If rasterization happens on a server somewhere Out There on the Internet, the architecture is not responsive enough to truly show in-between images; systems like Leaflet use clever animations to hide this fact.</p> <div class="image-part"> <div class="w-50"> <h5>Leaflet + OpenStreetMap.org tiles</h5> <p> A popular map style displayed on openstreetmap.org; zooming in jumps between different zoom levels; a 250 millisecond scale transition is handled by Leaflet. </p> <p>source: <a href="https://openstreetmap.org">OpenStreetMap</a></p> </div> <div class="w-50"> <video src="/images/web-map-performance/osm_zoom_in.mp4#t=0.001" controls="" /> </div> </div> <div class="image-part"> <div class="w-50"> <h5>Google Maps Fallback</h5> <p> Google Maps loads a stepped-zoom fallback map renderer initially, and then swaps to a WebGL-based real-time renderer if browser support is detected. It snaps between zooms with no animation. </p> <p>source: <a href="https://maps.google.com">Google Maps</a></p> </div> <div class="w-50"> <video src="/images/web-map-performance/google_maps_canvas.mp4#t=0.001" controls="" /> </div> </div> <p>Like Myst, a cross-fade animation helps achieve <a href="https://en.wikipedia.org/wiki/Persistence_of_vision#Other_theories_for_motion_perception_in_film">persistence of vision</a> for what is actually a totally new image. “Cheating” in this way for maps can be acceptable if the blurry appearance of the map in transition is not important.</p> <h2 id="fractional-zoom-levels">Fractional zoom levels</h2> <p>Are infinite, fractional zoom states possible by rounding to the nearest level? This works fine if your images are satellite photographs - the key distinction is that the features in your map are intended to be <strong>scaled in world space:</strong></p> <ul> <li>At zoom level 5, a feature is 20 px wide.</li> <li>At zoom level 6, the feature is 40 px wide.</li> <li><strong>At zoom level 5.5, the feature is about 30 px wide</strong> (actually a bit less because of the exponential relationship)</li> </ul> <div class="image-part"> <div class="w-50"> <h5>Infinite zoom levels</h5> <p> Displaying satellite imagery works just fine with <code>img</code> tags and continuous zoom; the images are scaled smoothly via CSS transforms before the next or previous level is loaded. </p> <p>source: <a href="https://s2maps.eu/">Sentinel-2 cloudless - https://s2maps.eu</a> by <a href="https://eox.at/">EOX IT Services GmbH</a> (Contains modified Copernicus Sentinel data 2016 &amp; 2017)&lt;/a&gt;</p> </div> <div class="w-50"> <video src="/images/web-map-performance/satellite.mp4#t=0.001" controls="" /> </div> </div> <p><a href="https://openseadragon.github.io">OpenSeadragon</a> is another general purpose library for “deep zoom” images that implements fractional zooming with simple browser APIs; it works great for museum collections and satellite imagery.</p> <p>But this breaks down if your intention is to <strong>keep features consistent in screen space, like cartographic map labels with an assigned font size of 20px, or schematic roads with an assigned width of 5px:</strong></p> <ul> <li>At zoom level 5, the label is 20 px tall.</li> <li>At zoom level 6, the label is 20 px tall.</li> <li>At zoom level 5.49999, the label is <strong>about 40 px tall.</strong></li> <li>At zoom level 5.50000, the label is <strong>about 10 px tall.</strong></li> </ul> <div class="image-part"> <div class="w-50"> <h5>Hacking it with Leaflet</h5> <p> Attempting to display fractional zoom levels with pre-rasterized schematic maps means that the map is jarringly pixelated at some levels, and label sizes swing between too small and too large - <b>coherent cartographic design becomes impossible. </b> </p> <p>source: <a href="https://maps.google.com" class="light-silver">OpenStreetMap</a></p> </div> <div class="w-50"> <video src="/images/web-map-performance/smoothwheelzoom.mp4#t=0.001" controls="" /> </div> </div> <p><strong>The Myst approach for map display is unacceptable if you demand both screen-space rendering of features and fractional zoom levels.</strong> If you can compromise by having stepped zooms, non-realtime-rendered maps are significantly easier to implement.</p> <h2 id="the-doom-approach-to-map-rendering">The “Doom” approach to map rendering</h2> <p>The correct fractional-zoom approach to rendering is true <b>real-time maps, where rasterization of map features happens Doom-style - multiple times a second</b>, ideally 30-60. This is only practical to accomplish on GPUs, via a low-level API like OpenGL/WebGL, Direct3D or Metal.</p> <p>The pinnacle of this approach for developers to reuse in web apps is the source-available <a href="https://docs.mapbox.com/mapbox-gl-js/api/">Mapbox GL JS</a> library or a <a href="http://maplibre.org">fork</a> which is still BSD-licensed. Google Maps for the web now uses its WebGL version for all browsers; there are also less widely adopted renderers like <a href="http://harp.gl">Harp.GL</a> and <a href="http://tangram.city">Tangram JS</a>. The flow of data is something like this:</p> <ul> <li>Geographic features are projected into Web Mercator, sliced into tiles, and stored in a vector SVG-like format, like GeoJSON or <a href="https://github.com/mapbox/vector-tile-spec">MVT protocol buffers.</a></li> <li>Tiles are fetched over the network and vertex data is moved to GPU memory. Polygons need to be <a href="https://en.wikipedia.org/wiki/Polygon_triangulation">converted into triangles</a>, because GL-like graphics APIs only display triangles and textures. Text needs to be converted to textures or <a href="https://computergraphics.stackexchange.com/a/2151">signed distance fields</a> for map labeling.</li> <li>Programmable shaders extrude linear features into screen-space lines - see <a href="https://mattdesl.svbtle.com/drawing-lines-is-hard">Drawing Lines is Hard</a> - and then composite them with triangle-ized polygons and texture-ized text on screen. <strong>A powerful map engine can allow user customization at any point in this pipeline.</strong></li> </ul> <div class="image-part"> <div class="w-50"> <h5>Google Maps WebGL</h5> <p>Google Maps uses WebGL for real-time rasterization, which means that text labels are always sized correctly, and features are never blurry, even when data has not finished loading for the displayed zoom level.</p> <p>source: Google Maps</p> </div> <div class="w-50"> <video src="/images/web-map-performance/google_maps_zoom.mp4#t=0.001" controls="" /> </div> </div> <h2 id="the-web-is-a-difficult-platform-for-real-time-rasterization">The web is a difficult platform for real-time rasterization</h2> <p>Map applications on native platforms - desktop, iOS, Android - take the real-time rendering approach, because they have direct access to powerful APIs for doing mappy things - Metal, Direct3D for drawing, Core Text and Uniscribe for displaying fonts. Apps for the web are constrained by a weak platform and also the need to be cross-browser, leading rich design tools like Figma to <a href="https://www.figma.com/blog/building-a-professional-design-tool-on-the-web/">ship their own implementation of low level graphics APIs</a>.</p> <h2 id="how-to-build-fast-maps">How to build fast maps</h2> <p>Software developers and cartographers building mapping systems will describe an interactive map being <em>fast</em> or <em><a href="https://english.stackexchange.com/questions/38945/what-is-wrong-with-the-word-performant">performant (sic)</a></em> without any context as to what <strong>performance actually means.</strong> Performance, in the abstract, is used to justify building a real-time rendered system over the “obsolete” technology of pre-rendered tiles. By most quantifiable measures - like vertices rasterized per second - GL maps blow away the alternatives.</p> <p><strong>What end users of applications actually perceive as a high performance web app is low latency.</strong> A web map system should respond instantaneously to user input, zooming as soon as a wheel is scrolled, and panning perfectly in sync with mouse movements. The point here is that <strong>a non-real-time rasterized map system can be as fast or faster</strong> than a GL one, by choosing to show only discrete zoom levels, minimizing network latency, and limiting the total amount of data sent to the browser.</p> <div class="image-part"> <div> <h5>WebGL Map Latency at 2560x1600</h5> <p> MapLibre GL displaying a typical cartographic map style at full screen resolution on a 2016 MacBook Pro. Zooming is nice, with real-time label collisions, but panning the map is choppy. You can reproduce this experiment on <a href="https://maplibre.org/maplibre-gl-js-docs/example/fullscreen/">this example page.</a> </p> <p>source: <a href="https://maptiler.com">MapTiler</a>, <a href="https://openstreetmap.org">OpenStreetMap</a></p> </div> <div class="w-50"> <video src="/images/web-map-performance/gl_2k.mp4#t=0.001" controls="" class="w-100" /> </div> </div> <div class="image-part"> <div> <h5>Leaflet map at 2560x1600</h5> <p> Leaflet displays chunky zoom levels - objectively worse than a real-time rasterized system - but panning the map has very low latency, because the GPU is simply moving textures around. </p> <p>source: <a href="https://openstreetmap.org">OpenStreetMap</a></p> </div> <div class="w-50"> <video src="/images/web-map-performance/leaflet_2k.mp4#t=0.001" controls="" class="w-100" /> </div> </div> <h2 id="so-which-approach-should-i-use">So which approach should I use?</h2> <p><strong>It depends.</strong></p> <p>Decisions on mapping technology, and committing to tradeoffs, are <a href="https://en.wikipedia.org/wiki/Wicked_problem">wickedly cross-functional</a> - spanning backend and frontend software engineering, graphic design, user experience and product management.</p> <p>In the same way pre-rendered images were good enough to make Myst a best-selling game, non-realtime rendering of maps is good enough for some, maybe even the majority, of web map use cases today. If you’re building a whizbang mapping demo with 3D flythroughs to show your company execs, a real-time-rendered system - the Doom approach - is the best choice; if you’re building a site for helping people find the nearest COVID vaccine, the <strong>simplest solution is the best solution</strong>, and that usually means stepped-zoom maps.</p> <p>Some good reasons to go real-time rendering:</p> <ul> <li>Your application is built around a full-screen interactive map, and <strong>smooth zooming is a core part of the experience.</strong></li> <li>You need to display 3D geometry or rotate the map.</li> <li>You intend to display a high density of labels, and need real-time collision between them.</li> </ul> <p>Some good reasons to use Leaflet-style maps:</p> <ul> <li>The map is just a part of the application, <a href="https://en.wikipedia.org/wiki/Locator_map">like an inset or locator map.</a></li> <li>The map is never zoomed, only panned or completely static.</li> <li><strong>Chunky, stepped zooms are an acceptable user experience.</strong></li> </ul> <h2 id="further-reading">Further Reading</h2> <ul> <li><a href="https://www.w3.org/2020/maps/">W3C Maps for the Web</a></li> <li><a href="https://medium.com/google-design/google-maps-cb0326d165f5">Google Design: Prototyping a Smoother Map</a></li> </ul> Mon, 11 Oct 2021 00:00:00 +0000 https://bdon.org/2021/10/11/web-map-performance https://bdon.org/2021/10/11/web-map-performance Web maps without centralized services bdon.org <p>How many web applications or mobile apps do you use that have a map component? Rideshare apps display the location of drivers and passengers; ratings sites show the locations of restaurants; Craigslist and Wikipedia show contextual location for classifieds or encyclopedia articles. High quality, interactive maps are pervasive and simply fade into the background for end users.</p> <p>The COVID-19 pandemic has created a surge of new mapping applications. Beyond websites that <a href="https://coronavirus.jhu.edu/map.html">visualize the case count in different regions</a>, maps have become <strong>critical computing infrastructure</strong> for delivering health services.</p> <div class="image-part"> <div class="w-50"> <h5>Maps as Infrastructure</h5> <p>The New York City government uses Google Maps to help residents find a COVID-19 testing location near them.</p> <p>source: <a href="https://coronavirus.health.ny.gov/home">coronavirus.health.ny.gov</a></p> </div> <div class="w-50"> <img src="/images/web-map-services/NYCCovidSites.png" /> </div> </div> <div class="image-part"> <div class="w-50"> <h5>Maps and Citizen Tech</h5> <p>The Taiwan government rationed face masks at pharmacies and published inventories via a public API; this enabled citizen developers, in combination with geocoding services and third-party basemaps, to create a variety of web and smartphone applications.</p> <p>source: <a href="https://www.facebook.com/g0v.tw/posts/3580268872014373/">facebook.com/g0v.tw</a>, <a href="https://g0v.hackmd.io/@kiang/mask-info">江明宗</a></p> </div> <div class="w-50"> <img src="/images/web-map-services/Pharmacies.jpg" /> </div> </div> <p>For a developer who wants to integrate a map into their application, the choices are almost always to use a <strong>hosted, centralized map service</strong>; developer map mindshare is dominated by multinational companies. Some hosted map examples:</p> <ul> <li>The embeddable native maps on Google’s Android or Apple’s iOS/iPadOS/macOS/watchOS operating systems</li> <li>Google’s commercial web map offering (Google Maps JavaScript API)</li> <li>Microsoft’s recent release of Azure Maps and Amazon’s AWS Location Service</li> <li>Commercial map GIS companies such as ESRI, MapQuest, CloudMade, HERE and Mapbox; free hosted maps like <a href="http://openstreetmap.org">OpenStreetMap Carto</a> or <a href="http://maps.stamen.com">maps by Stamen Design</a></li> </ul> <h2 id="what-is-a-basemap">What is a basemap?</h2> <p>Typical parts of a map application include:</p> <ul> <li>Translation from search tokens or addresses to locations (geocoding)</li> <li>Determining the place name or administrative division of a location (reverse geocoding)</li> <li>Finding directions between two locations (routing)</li> <li>Overlaying of domain-specific geographic features, such as COVID-19 testing sites</li> <li><strong>Showing physical and cultural context</strong> on maps, such as city names, nearby points of interest, and roads</li> </ul> <p>It’s this last component that we usually call a <strong>basemap</strong> - especially if it <strong>displays map labels</strong>, and is zoomable or <strong>multi-resolution, implying the application of <em>cartographic generalization</em></strong>.</p> <div class="image-part"> <div class="w-50"> <h5>Map Labels</h5> <p>A basemap is most useful for context if it displays map labels. Labels may be in a single language, but might display more than one language, alternate names, or transcriptions: for example, Romaji labels on maps of Japan.</p> <p>source: <a href="https://openstreetmap.org">OpenStreetMap</a></p> </div> <div class="w-50"> <img src="/images/web-map-services/LabelScript.jpg" /> </div> </div> <div class="image-part"> <div class="w-50"> <h5>Generalization - More Art than Science</h5> <p>When the map scale is decreased - in this case by a factor of 2 - less relevant geographic features can be removed from the map. The ideal generalization <b>keeps the visual density of the map constant as scale is decreased</b>, even though the number of geographic features existing within those bounds increases exponentially.</p> <p>source: <a href="https://openstreetmap.org">OpenStreetMap</a></p> </div> <div class="w-50"> <img src="/images/web-map-services/Generalize.jpg" /> </div> </div> <p>Single-scale wayfinding maps you see in the real world are labeled and generalized by cartographers; multi-scale basemap services accomplish this in an <strong>automated way</strong>. The sophistication of computer programs to do this - especially at whole earth scale - can be grossly underestimated, even by experienced programmers. Good labeling and generalization are taken for granted, like good font rendering and typesetting - invisible when successful, glaringly flawed when unsuccessful.</p> <p>This also illustrates the key difference between a basemap and a dataset of geographic features, such as <a href="https://openstreetmap.org">OpenStreetMap</a>. <strong>OSM is not a cartographic product; it does not attempt any generalization or ranking of features.</strong> <a href="http://naturalearthdata.com">Natural Earth</a> is an example of a cartographic product - it include fields such as <code class="language-plaintext highlighter-rouge">scalerank</code> to assist in generalization, curated by human editors.</p> <p><strong>In theory, basemaps are fungible</strong> - the cartographic context required is similar among diverse applications. So why do developers - and as a consequence, the World Wide Web - gravitate towards a small handful of hosted map platforms?</p> <h2 id="mapmakers-victims-of-lofty-expectations">Mapmakers: Victims of Lofty Expectations</h2> <p>The basemap status quo is defined by the cutting edge commercial product, and right now that’s Google Maps. <strong>Users are accustomed to, and will demand, a seamless abstraction of the physical world.</strong> Map panning and zooming should be instantaneous, so designers of a high performance cartographic system must take into account:</p> <ul> <li>The completeness and quantity of the underlying geodata</li> <li>The arrangement and indexing of geodata to achieve low latency</li> <li>Tile schemes and partitioning for generalized data</li> <li>Protocols for fetching and caching those tiles over the network</li> <li>Choice of a rasterization API like Cairo or OpenGL and the flow of vertex data to them</li> </ul> <p>The desired end product is a videogame-like, sixty-frames-per-second experience, and map systems often make the same technical compromises as games: for example, a map system that smoothly resizes labels in real time may choose to precompute <a href="https://en.wikipedia.org/wiki/Signed_distance_function#Applications">signed distance fields</a> for text glyphs on the server and fetch them by <a href="https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane">codepoint ranges</a>. This works beautifully for languages that use at most a few hundred Latin characters, but navigating to places that use Han characters such as China or Japan will degrade performance. Thus a cartographic system demands holistic design around tradeoffs such as latency or localization capabilities.</p> <div class="image-part"> <div class="w-50"> <h5>Not Good Enough Anymore</h5> <p>Mapquest in the early 2000s required the user to click arrow buttons to pan and zoom; maps in 2020 are expected to respond instantly to mouse wheel scroll and finger pinch gestures.</p> <p>source: MapQuest, <a href="https://www.peterme.com/archives/000453.html" class="light-silver">peterme.com</a></p> </div> <div class="w-50"> <img src="/images/web-map-services/mapquest-2.png" /> </div> </div> <h2 id="serving-maps-best-left-to-bigcorps">Serving Maps: best left to BigCorps?</h2> <p>Given the demanding technical requirements above, it’s easy to be led into thinking <strong>maps are too hard for individual developers to solve and should be outsourced to a third-party hosted service.</strong> A cartographic system is very “full-stack” in nature, but the commoditization of some potential components, like PostGIS or HTTP accelerators, makes the overall task less daunting. Bigness isn’t really a constraint; the OpenStreetMap dataset as XML is <a href="https://planet.openstreetmap.org">about 100 gigabytes</a>. Let’s estimate 10x expansion to make a cartographic product; that’s still only a terabyte of data to put on a disk somewhere.</p> <p><strong>Developers believe something is too hard, until it isn’t.</strong> Issuing of SSL Certs was in practice limited to a few Certificate Authorities until Let’s Encrypt; Hosting of seekable video content was only done by big sites in concert with CDNs, but now we have the standardized, hardware-accelerated HTML <code class="language-plaintext highlighter-rouge">video</code> element and ubiquitous broadband. Email is a notable counterexample; you’ve been able to run your own Mail Transfer Agent since the beginning, but the Hobbesian underworld of spam and phishing drives users into the oligopoly of a few providers.</p> <p>Serving maps is hard but not insurmountable; I’ll suggest a factor limiting the landscape of web maps is not data bigness or the speed of slinging geodata down tubes, but licensing and realities of the market.</p> <h2 id="intellectual-property-fine-print">Intellectual Property, Fine Print</h2> <p><strong>Firstly, mapmaking businesses rightly assert copyright over their cartography.</strong> This far predates webmaps: <a href="https://en.wikipedia.org/wiki/Trap_street">Trap Streets</a> are a longstanding practice on print maps. This is often true even if the map is built from open data such as OSM - the derivation of a cartographic product, and quality of output, is “secret sauce” to achieve product differentiation.</p> <p><strong>Secondly, map serving easily admits a Software-As-A-Service (SaaS) business model.</strong> Shrink-wrapped software, or creating a piece of software and “selling it in a box”, has been out of vogue for decades, possibly over piracy concerns, or because it has less extractive potential on enterprise budgets. In addition to copyright, <strong>Terms of Service for hosted maps often prohibit combination with other geographic services, exclude specific use cases, or forbid caching.</strong> These contracts work against developers by inventing scarcity: even if you need a small subset of map tiles, they must be fetched and billed; don’t scrape the data and put it in version control.</p> <p><strong>The freemium, ToS-constrained nature of hosted map services disincentivizes innovation.</strong> Inability to swap out the Google Maps frontend means interesting problems like labeling and generalization can’t be attacked with piecemeal incrementalism. This tips developer’s scales toward <em>Buy</em> rather than <em>Build</em>, especially when the hosted pay-per-hit product starts out free, often as a <a href="https://en.wikipedia.org/wiki/Loss_leader">loss leader</a> for a <a href="https://en.wikipedia.org/wiki/Product_bundling">bundle</a> of geospatial services. These market realities leave some mapping use cases underserved by existing technology.</p> <h2 id="map-applications-ought-to-outlive-the-saas-business-lifecycle">Map applications ought to outlive the SaaS business lifecycle</h2> <p>Accessing a web map over the network isn’t always practical. Maps may need to be displayed on air-gapped internal applications, or work offline without cell tower reception.</p> <p>Also, websites and mobile applications are often built by organizations separate from their long-term maintainers (e.g. universities, museums, cultural institutions); ambitious visualization projects may be deterred by clients not wanting to foot a pay-per-hit subscription. An application depending on a hosted map service may be permanently disabled if the provider deprecates their API. <strong>Hard dependencies on hosted services make software worse</strong> - if your data visualization uses Google Maps, don’t count on it still working in a couple years.</p> <div class="image-part"> <div class="w-50"> <h5>Small-Scale Map Apps</h5> <p><a href="80s.nyc">80s.nyc</a> is a streetview-like application for navigating historical images of New York City. It can be useful for <a href="https://medium.com/@dougbarclay/nana-at-the-doorway-4cf91888233b">discovering lost pictures of your great-grandmother</a>. Depending on a hosted basemap API would expose non-commercial projects to the whims and business models of SaaS providers.</p> <p>source: <a href="https://80s.nyc">80s.nyc</a>, <a href="http://nycma.lunaimaging.com">NYC Department of Records / Municipal Archives</a></p> </div> <div class="w-50"> <img src="/images/web-map-services/80snyc.jpg" /> </div> </div> <h2 id="developers-ought-to-be-able-to-control-their-map-content">Developers ought to be able to control their map content</h2> <p>Self-hosted has some generic advantages - less phoning home means better security and privacy. For maps in particular, designers may want to customize the visual appearance of map features, exclude certain layers, or change the language of labels. These are all achievable to some degree with hosted vector map backends and client-side rendering, so DIY maps don’t necessarily win here.</p> <p>A more abstract ideal for DIY maps is <em>control over the underlying geodata.</em> Google Maps data has adjudicated on <a href="https://www.nytimes.com/2018/08/02/technology/google-maps-neighborhood-names.html">neighborhood names</a>, administrative boundaries, even the display of particular tourist attractions when zoomed out. Compare to OpenStreetMap: In theory, anyone can edit the map and communities can determine for themselves, say, whether a road’s bike lane is sufficiently hazard-free to be highlighted in green. Its availability under an open license (the copyleft ODbL) means developers could exert total control over their maps, even remixing additional datasets into basemaps. <strong>Cartographic authority was long ago exercised by governments; commoditization of printing technology transferred this authority to mapmaking and surveying firms; mobile computing has shifted this to Google and Apple Maps. What tools must be built to put mapmaking in the hands of individuals?</strong></p> <div class="image-part"> <div class="w-50"> <h5>14th Century Maps</h5> <p>Maps were once so resource-demanding to only be commissioned by emperors. Centuries-old maps are often expressions of state power; white rectangles on the <i>Da Ming Hunyi Tu</i> are paper labels overwriting Chinese placenames with Manchu ones.</p> <p>source: <a href="https://en.wikipedia.org/wiki/Da_Ming_Hunyi_Tu">大明混一圖</a></p> </div> <div class="w-50"> <img src="/images/web-map-services/Da-ming-hun-yi-tu.jpg" /> </div> </div> <div class="image-part"> <div class="w-50"> <h5>Which Name?</h5> <p>Google maps displays "New Zealand", while OpenStreetMap-based maps that default to the <span class="code">name</span> tag display "New Zealand / Aotearoa"</p> <p>source: Google Maps, OpenStreetMap</p> </div> <div class="w-50"> <img src="/images/web-map-services/NewZealand.png" /> </div> </div> <p>To follow along, subscribe via <a href="/feed.xml">Atom/RSS</a>.</p> <h2 id="recommended-further-reading">Recommended Further Reading</h2> <ul> <li><a href="https://joemorrison.medium.com">A Closer Look with Joe Morrison</a></li> <li><a href="https://www.justinobeirne.com">Justin O’Beirne</a></li> </ul> Mon, 21 Dec 2020 00:00:00 +0000 https://bdon.org/2020/12/21/web-map-services https://bdon.org/2020/12/21/web-map-services