MapContext.includePoints

Adjust (move and zoom) the visible area of the map to display the specified coordinates in the map view area.

Parameters

Property

Type

Required

Description

points

Array<Object>

Yes

The list of coordinate points to be displayed within the visible area of the map.

Example:

copy
[
{ latitude:12.000,
longitude:32.000
},
{latitude:12.000,
longitude:32.000
}]

padding

Array<Number>

No

The distance from the edges of the polygon (that is formed by the coordinate points) to the edges of the map.

  • Format: [top, right, bottom, left]. If there is only one data item, the padding for top, bottom, right, and left will be the same.
  • Default value: [0,0,0,0]

success

Function

No

The callback function that is called upon successful call.

fail

Function

No

The callback function that is called upon failed call.

complete

Function

No

The callback function that is called upon call completion (to be executed upon either call success or failure).

fail callback function

The parameter of the fail callback function is an object, where:

  • error : indicates the error code
  • errorMessage : indicates the error message.

Error code

Error code

Error message

Further action

2

Invalid parameters. For example, the data type is incorrect.


Fill in the correct parameters per the Parameters section.

Sample code

copy
this.mapCtx = my.createMapContext('map');
this.mapCtx.includePoints({
    points: [
        {
            latitude: 39.935029,
            longitude: 116.384377,
        },
        {
            latitude: 39.939577,
            longitude: 116.388331,
        },
      ],
      padding: [48, 48, 48, 48],
      success: (res) => {
        console.log("success", res);
      },
      fail: (error) => {
        console.log("fail", error);
      },
});