MapContext.changeMarkers
Add, delete, or update the specified location marker.
Parameters
Property | Type | Required | Description |
add | Array<Object> | No | The markers arrays to add. |
remove | Array<Object> | No | The markers arrays to delete. |
update | Array<Object> | No | The markers arrays to update. |
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). |
Sample code
copy
this.mapCtx = my.createMapContext('map');
this.mapCtx.changeMarkers({
add: [{
// The image path in the project directory
iconPath: 'https://gw.alipayobjects.com/mdn/rms_dfc0fe/afts/img/A*x9yERpemTRsAAAAAAAAAAAAAARQnAQ',
// marker id
id: 10,
// latitude
latitude: 30.274960,
// longitude
longitude: 120.125872,
width: 20,
height: 25
}, {
iconPath: 'https://gw.alipayobjects.com/mdn/rms_dfc0fe/afts/img/A*x9yERpemTRsAAAAAAAAAAAAAARQnAQ',
id: 20,
latitude: 30.274960,
longitude: 120.125872,
width: 50,
height: 50,
// the customized callout
customCallout: {
type: 2,
time: '1',
},
// used together with iconPath
iconAppendStr: 'xxx mall, xxx street'
}],
success: res => {
console.log(res);
},
fail: error => {
console.log(error);
},
complete: res => {
console.log(res);
}
});