Skip to main content
Create a context object to control a map component.

Parameters

PropertyTypeRequiredDescription
mapIdStringYesMap component ID

Return Value

Returns a MapContext object with control methods.

MapContext Methods

MethodDescription
getCenterLocation()Get map center coordinates
moveToLocation()Move to current location
includePoints()Adjust view to include points
getRegion()Get visible region
getScale()Get current zoom level

Code Example

const mapCtx = my.createMapContext('myMap');

mapCtx.getCenterLocation({
  success: (res) => {
    console.log('Center:', res.latitude, res.longitude);
  }
});
<map id="myMap" latitude="{{lat}}" longitude="{{lng}}" />