Add a custom control programmatically
Adding a custom control programmatically allows developers to have more control is ideal for applications that require dynamic logic, event-driven behaviour, or a deeper integration with a framework like React.
Programmatic controls allow developers to register custom control elements manually by calling map.addControl()
and providing a control implementation. Custom controls are instantiated using the MaptilerCustomControl
class. The element that should be used can be provided either as the element itself, or as its CSS selector.
Learn more
Check out the MaptilerCustomControl API reference to learn all the options to add custom controls to your map interface.
Related examples
An extension of MapLibre GL JS