For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
MapTiler Marker Layout for MapTiler SDK
Get it from npm registry
View source code on GitHub
The Marker Layout is a helper to create non-colliding marker overlays on top of MapTiler SDK. Fed by a vector layer from a tileset or a GeoJSON source, it can be tuned with plenty of options. Thanks to its non-opinionated and logic-only approach, it lets you bind any kind of rendering you wish for your markers: vanilla HTML div, React components, floating canvas, animated SVGs or Lotties 1, etc. as it computes the position and size of the markers but lets you handle the rendering part.
The SDK’s own Marker also handles collisions, but it creates a DOM element for every marker, which gets slow with thousands of points. A symbol layer can show that many points, but you can’t style them with HTML. Marker Layout sits in between: it reads features from vector tiles or GeoJSON, works out which markers fit on screen, and tells your app which ones to create, update, or remove.
Marker Layout or SDK marker
Both handle collisions between markers. Choose by where your points come from and how many there are.
Use the SDK marker
- You create markers in your own code, such as search results, user-added places, or draggable pins.
- You want built-in shapes, colors that follow the map style, animations, UI states, or altitude, without an extra package.
- You have dozens to a few hundred points.
Use Marker Layout
- Your points come from a vector tileset or a large GeoJSON source, with hundreds or thousands of features.
- You want to reuse DOM elements. After each update, Marker Layout lists the new, removed, and moved markers, so you can update existing elements instead of recreating them.
- You want to group several features into one marker, or rank features with your own sorting function.
- You render markers with UI components, such as React, Svelte, or Vue, or with animations such as Lottie.
Get started
Check out the How to create non-colliding marker overlays example. In this get started we will create a Marker Layout to display the information from the city and town label layers.
API reference
This reference documents every object and method available. Each section describes classes or objects as well as their properties, parameters, methods, and associated events. Many sections also include inline code examples and related resources.
Some concepts
The Marker Layout…
- computes screen-space bounding box logic
- can be provided the desired marker size and relative anchor point
- is fed with one or multiple vector layer
- can only use point features
- create non-overlapping bounding boxes
- can filter and sort features based on vector feature properties
- sorting can be done with a function, so that rank can come from an external source
- can group multiple vector features into each marker
- when updated will retrieve three lists of markers relative to the previous state: the new, the removed and the moved markers
- does not enforce how the actual visual markers (eg. div) should be created, cached, pooled, reused or deleted
Related examples
-
Lottie is a file format for vector graphics animation. They can be scaled without pixelation or loss of quality, just like an SVG file. It is intended as a lighter alternative to animated GIFs and APNG files for use in the web and mobile and desktop applications. Read more about Lottie file format. ↩