Maplibre Pbf

19 views
Skip to first unread message

Thora Buckner

unread,
Aug 5, 2024, 1:03:54 PM8/5/24
to tivinecfi
MapLibreGL JS is a TypeScript library that uses WebGL to render interactive maps from vector tiles in a browser. The customization of the map comply with the MapLibre Style Spec. It is part of the MapLibre ecosystem, with a counterpart for Android, iOS and other platforms called MapLibre Native.

As a mitigation for Cross-Site Scripting and other types of web security vulnerabilities, you may use a Content Security Policy (CSP) to specify security policies for your website. If you do, MapLibre GL JS requires the following CSP directives:


For strict CSP environments without worker-src blob: ; child-src blob: enabled, there's a separate MapLibre GL JS bundle (maplibre-gl-csp.js and maplibre-gl-csp-worker.js) which requires setting the path to the worker manually:


Including it with a in the head of the document via the UNPKG CDN is the simplest and easiest way to provide the CSS, but it is also bundled in the MapLibre module, meaning that if you have a bundler that can handle CSS, you can import the CSS from maplibre-gl/dist/maplibre-gl.css.


The MapLibre GL JS (.js & .css) are distributed via UNPKG.com.You can view a listing of all the files in the MapLibre GL JS package by appending a / at the end of the MapLibre slug. This is useful to review other revisions or to review the files at UNPKG or the LICENSE. See examples in the following table:


MapLibre GL JS is a powerful open-source library that uses WebGL to render interactive maps from vector tiles in a browser. deck.gl's MapView can sync perfectly with the camera of MapLibre, at every zoom level and rotation angle.


The interleaved mode renders deck.gl layers into the WebGL2 context created by MapLibre. If you need to mix deck.gl layers with MapLibre layers, e.g. having deck.gl surfaces below text labels, or objects occluding each other correctly in 3D, then you have to use this option.


The overlaid mode renders deck.gl in a separate canvas inside the MapLibre's controls container. If your use case does not require interleaving, but you still want to use certain features of maplibre-gl, such as maplibre-gl controls (e.g. NavigationControl, Popup) or plugins (e.g. navigation directions, mapbox-gl-draw), then you should use this option.


The reverse-controlled mode renders deck.gl above the MapLibre container and blocks any interaction to the base map. If your use case does not require interleaving, but you need to implement your own pointer input handling, have multiple maps or a map that does not fill the whole canvas (with Deck's multi-view feature), you need this to allow deck.gl manage the map's size and camera.


Both the interleaved and the overlaid options are supported by the @deck.gl/mapbox module. This is recommended approach for developers coming from the MapLibre ecosystem, as it can easily switch between interleaved and overlaid rendering, as well as being compatible with other MapLibre controls and plugins.


When you choose the reverse-controlled option, the DeckGL React component acts as the root component, and the react-map-gl Map is a child. In this case, Map will automatically interpret the deck.gl view state (i.e. latitude, longitude, zoom etc), so that deck.gl layers will render as a synchronized geospatial overlay over the underlying map.


One of the important tools for creating interactive applications with Amazon Location is MapLibre. MapLibre is primarily a rendering engine for displaying maps in a web or mobile application. However, it also includes support for plug-ins, and provides functionality for working with other aspects of Amazon Location. The following describes tools that you can use, based on the area of location that you want to work with.


To display maps in your application, you need a map rendering engine that will use the data provided by Amazon Location, and draw to the screen. Map rendering engines also provide functionality to pan and zoom the map, or to add markers or pushpins and other annotations to the map.


Amazon Location Service recommends rendering maps using the MapLibre rendering engine. MapLibre GL JS is an engine for displaying maps in JavaScript, while MapLibre Native provides maps for either iOS or Android.


Many libraries use the open standard GeoJSON formatted data. Amazon Location Service provides a library to support using GeoJSON in JavaScript applications. For more information, see the next section, Amazon Location SDK and libraries.


The Amazon Location MapLibre geocoder plugin is designed to make it easier for you to incorporate Amazon Location functionality into your JavaScript applications, when working with map rendering and geocoding using the maplibre-gl-geocoder library.


This code sets up a Maplibre GL JavaScript map with Amazon Location geocoding capabilities. It uses authentication via Amazon Cognito Identity Pool to access Amazon Location resources. The map is rendered with a specified style and center coordinates, and allows to search for places on the map.


Some of these example use the Amazon Location Client. The Amazon Location Client is based on the AWS SDK for JavaScript V3 and allows for making calls to Amazon Location through a script referenced in an HTML file.


Add an autocomplete search box to your map with just a few lines of code. Ourplugin takes care of all the UI and API calls for you, and implements best practicesincluding debouncing of requests, caching of recent results, and zooming the mapto the results when the user makes a selection.


If you like to keep your frontend simple and don't want to use JS build tooling, we have you covered! You can easily usethe plugin by linking to the module on unpkg. The library is exported via the global maplibreSearchBox, but otherwisefunctions exactly as if you used npm package tooling.


On low zooms, the focus point is often unuseful for contextual results (e.g., on zoom 0, the whole world is visible, sothe center is not valuable). This controls at what zoom the center is used to influence results.


For address-based forward geocoding applications, it often makes sense to use the forward geocoding (/search) endpointrather than autocomplete search, once you know that the user has completed their input. The full forward geocodingendpoint is able to interpolate addresses, and may provide better results with complete input than the autocompleteendpoint. Opting in to this behavior will send a final forward geocoding request if the user presses enter.


A callback to be invoked whenever a result is selected by the user. This is invoked with a single argument, thePeliasFeature for the result. This allows you take an action (such as autofilling your own form).


An optional override to the base API URL. This defaults to the primary Stadia Maps API endpoint. If you wantto use our EU endpoints to ensure traffic is handled by EU servers,set the baseUrl to -eu.stadiamaps.com.


One approach that has been used successfully to do that is to copy the filesfrom the app's assets directory to another directory, e.g. the app's cachedirectory, and then reference that location.See e.g. issues -maplibre-gl/issues/338and -maplibre-gl/issues/318

3a8082e126
Reply all
Reply to author
Forward
0 new messages