# Object table JS plugin
# Control the form flow
This type of requirement needs to be implemented through the following APIs:
# beforeMapViewRenderMap()
Parameter:
context: Object
: The context of the fieldoptions: Object
: Gets the map containeroptions.container
: Map drawing placeholder, container
Return:
If there is no return, this method intercepts the original map and redraws the map
Usage:
beforeMapViewRenderMap happens before the map is drawn, intercepting the original map drawing
export default {
beforeMapViewRenderMap(context, options) {
FxUI.libs.require('map').then(map => {
map.create({
center: {lng: 116.33202, lat: 39.9771},
consume: {apiName: 'AccountAddrObj', bizKey: 'list_map', bizSource: 'udobj', consumeCount: 1, moduleKey: "google_map_app", paraKey: "google_map_call_limit"},
container: options.container,
fullscreen: true,
isFromSwitch: false,
scaleControl: true,
zoom: 3,
zoomControl: true,
zooms: [1, 20]
}).then((res) => {
ownerMap = this.map = res;
this.beforeMapViewAddMaker(context, this.dataList);
});
});
}
}
# beforeMapViewAddMaker()
Parameter:
context: Object
: The context of the fieldlist: Array
: List page datalist[i].location
: Anchor field
Return:
If there is no return, this method intercepts the original map instance to generate marker markers and displays aggregation points on the map instance
Usage:
beforeMapViewAddMaker occurs after the map is drawn and before markers are generated on the map instance
For setMarkerCluster, please refer to the map internationalization interface document (https://wiki.firstshare.cn/pages/viewpage.action?pageId=172156028 (opens new window))
export default {
beforeMapViewAddMaker(context, list){
if (this.map && list) {
var infoItem = _.findWhere(context.viewInfo, {name: 'map_view'})
var columns = []
_.each(infoItem.fields, function(a) {context.fields[a] && columns.push(context.fields[a])})
this.map.newMap.setMarkerCluster(list.filter(item => {!!item.location}).map((item,index) => {
const pos = item.location.split('#%$');
var contents = _.map(columns, function(aa) {
return {
title: aa.label,
content: item[aa.api_name] || '--'
}
})
return {
color: '#68a4ff',
lngLat: pos,
contents: contents
}
}),{onClick: this._onShowInfo});
this.dataList = list;
}else {
this.dataList = list;
}
}
}
# beforeMapViewCreate()
Parameter:
context: Object
: The context of the fieldparams: Object
: The parameter to parseparams.queryParam
: The list page requests parameters for the interfaceparams.queryParam.search_query_info
: A parameter in the form of a JSON string, which contains the limit on the number of data bars and the starting data index
Return:
This method returns the parameters of the request interface of the list page
Usage:
Before the MapViewCreate page is rendered, change the parameters of the page interface parameters, such as the data limit of the map list
export default {
beforeMapViewCreate(context,params) {
var r = JSON.parse(params.queryParam.search_query_info);
r.limit = 2000;
params.queryParam.search_query_info = JSON.stringify(r);
return Promise.resolve(params);
},
}
# beforeMapViewFetch()
Parameter:
context: Object
: The context of the fieldparams: Object
: The map list requests parameters of the interface, and the parameter structure is the same as above
Return:
This method returns the parameters of the request interface of the list page
Usage:
beforeMapViewFetch occurs before the map list request and changes the interface parameter parameters
export default {
beforeMapViewFetch(context,params) {
var r = JSON.parse(params.search_query_info);
r.limit = 2000;
params.search_query_info = JSON.stringify(r);
return Promise.resolve(params);
},
}
# beforeMapViewDestroy()
Parameter:
context: Object
: The context of the field
Return:
No return, new maps drawn are destroyed before the map is destroyed
Usage:
beforeMapViewDestroy occurs before the map is destroyed
export default {
beforeMapViewDestroy(context) {
ownerMap = null;
this.map = null;
}
}
# getIconIndex()
Parameter:
context: Object
: The context of the fieldindex: Number
: Serial number of the map list droplet, custom serial number
Return:
None returned
Usage:
getIconIndex occurs before the map list drop label sequence number is generated, changing the original increment order to custom
export default {
getIconIndex(context,index){
index = '';
return Promise.resolve(index);
},
}
Example: Draw a map using the beforeMapViewRenderMap method
export default {
beforeMapViewRenderMap(context, options) {
FxUI.libs.require('map').then(map => {
map.create({
center: {lng: 116.33202, lat: 39.9771},
consume: {apiName: 'AccountAddrObj', bizKey: 'list_map', bizSource: 'udobj', consumeCount: 1, moduleKey: "google_map_app", paraKey: "google_map_call_limit"},
container: options.container,
fullscreen: true,
isFromSwitch: false,
scaleControl: true,
zoom: 3,
zoomControl: true,
zooms: [1, 20],
mapSwitchedFn: ({originMap})=>{
console.log('切换地图', arguments)
originMap.setZoom(3)
this.beforeMapViewAddMaker(context, this.dataList);
}
}).then((res) => {
this.beforeMapViewAddMaker(context, this.dataList);
});
});
},
}