Map

MMap is the root element in the hierarchy. To initialize it, pass to the object constructor:

<!-- Create a map container -->
<div id="root"></div>
const {MMap} = mappable;

// Initialize the map
const map = new MMap(

  // Pass the link to the HTMLElement of the container
  document.getElementById('root'),

  // Pass the map initialization parameters
  {
    location: {
      zoom: 10,
      center: [25.229762, 55.289311]
    }
  }
);

All JS API objects are initialized according to their own rules, but are added to the map using the addChild() method called from the map instance. You can remove objects using the symmetric removeChild() method:

const {MMap, MMapLayer} = mappable;

// Initialize the map
const map = new MMap(...);

// Initialize a layer
const layer = new MMapLayer(...);

// Add this layer to the map
map.addChild(layer);

Initialization parameters

Some parameters passed to objects during initialization are required, others are optional. For example, the location field of the MMap component is required, whereas the behaviors field is optional.

const {MMap} = mappable;

const map = new MMap(document.getElementById('root'), {
  location: {
    zoom: 10,
    center: [25.229762, 55.289311]
  },
  behaviors: ['drag', 'scrollZoom', 'pinchZoom', 'dblClick']
});

Learn more about initialization parameters of each component.

Next