forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddressMatchService.js
More file actions
73 lines (66 loc) · 2.37 KB
/
AddressMatchService.js
File metadata and controls
73 lines (66 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import L from 'leaflet';
import {ServiceBase} from './ServiceBase';
import '../core/Base';
import {AddressMatchService as CommonMatchAddressService} from '@supermap/iclient-common';
/**
* @class L.supermap.addressMatchService
* @constructs L.supermap.addressMatchService
* @classdesc 地址匹配服务
* @category iServer AddressMatch
* @extends L.supermap.ServiceBase
* @example
* L.supermap.addressMatchService(url,options)
* .code(function(result){
* //doSomething
* })
* @param url - {string} 地址匹配服务地址
* @param options {Object} 地址匹配服务可选参数。如:data - {number}
*
*/
export var AddressMatchService = ServiceBase.extend({
initialize: function (url, options) {
ServiceBase.prototype.initialize.call(this, url, options);
},
/**
* @function L.supermap.addressMatchService.prototype.code
* @description 获取正向地址匹配结果。
* @param params - {Object} 正向匹配参数。
* @param callback - {function} 请求结果的回调函数。
*/
code: function (params, callback) {
var me = this;
var addressMatchService = new CommonMatchAddressService(me.url, {
proxy: me.options.proxy,
serverType: me.options.serverType,
eventListeners: {
scope: me,
processCompleted: callback,
processFailed: callback
}
});
addressMatchService.code(me.url + '/geocoding', params);
},
/**
* @function L.supermap.addressMatchService.prototype.decode
* @description 获取反向地址匹配结果。
* @param params -{Object} 反向匹配参数。
* @param callback -{function} 请求结果的回调函数。
*/
decode: function (params, callback) {
var me = this;
var addressMatchService = new CommonMatchAddressService(me.url, {
proxy: me.options.proxy,
serverType: me.options.serverType,
eventListeners: {
scope: me,
processCompleted: callback,
processFailed: callback
}
});
addressMatchService.decode(me.url + '/geodecoding', params);
}
});
export var addressMatchService = function (url, options) {
return new AddressMatchService(url, options);
};
L.supermap.addressMatchService = addressMatchService;