IControl class

Interface for interactive controls added to the map. This is a specification for implementers to model: it is not an exported method or class.

Controls must implement onAdd and onRemove, and must own an element, which is often a div element. To use Mapbox GL JS's default control styling, add the mapboxgl-ctrl class to your control's node.

class HelloWorldControl implements IControl {
  DivElement _divElement;
  @override
  String getDefaultPosition() {
    return 'bottom-left';
  }

  @override
  HtmlElement onAdd(MapboxMap map) {
    _divElement = DivElement();
    _divElement.text = 'Hello World';
    return _divElement;
  }

  @override
  onRemove(MapboxMap map) {
    _divElement.remove();
  }
}

Constructors

IControl.fromJsObject(IControlJsImpl jsObject)
Creates a new IControl from a jsObject.

Properties

hashCode int
The hash code for this object.
no setterinherited
jsObject → IControlJsImpl
JS object.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getDefaultPosition() String
Optionally provide a default position for this control. If this method is implemented and {@link MapboxMap#addControl} is called without the position parameter, the value returned by getDefaultPosition will be used as the control's position.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAdd(MapboxMap map) HtmlElement
Register a control on the map and give it a chance to register event listeners and resources. This method is called by {@link MapboxMap#addControl} internally.
onRemove(MapboxMap map) → dynamic
Unregister a control on the map and give it a chance to detach event listeners and resources. This method is called by {@link MapboxMap#removeControl} internally.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited