File tree Expand file tree Collapse file tree 1 file changed +21
-17
lines changed Expand file tree Collapse file tree 1 file changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,24 @@ export class Mapbox implements GeocoderAPI {
21
21
this . options . reverseQueryParams . access_token = accessToken ;
22
22
}
23
23
24
+ _getProperties ( loc ) {
25
+ const properties = {
26
+ text : loc . text ,
27
+ address : loc . address
28
+ } ;
29
+
30
+ for ( let j = 0 ; j < ( loc . context || [ ] ) . length ; j ++ ) {
31
+ const id = loc . context [ j ] . id . split ( '.' ) [ 0 ] ;
32
+ properties [ id ] = loc . context [ j ] . text ;
33
+
34
+ // Get country code when available
35
+ if ( loc . context [ j ] . short_code ) {
36
+ properties [ 'countryShortCode' ] = loc . context [ j ] . short_code ;
37
+ }
38
+ }
39
+ return properties ;
40
+ }
41
+
24
42
geocode ( query : string , cb : GeocodingCallback , context ?: any ) : void {
25
43
const params = this . options . geocodingQueryParams ;
26
44
if (
@@ -46,26 +64,11 @@ export class Mapbox implements GeocoderAPI {
46
64
bbox = L . latLngBounds ( center , center ) ;
47
65
}
48
66
49
- const properties = {
50
- text : loc . text ,
51
- address : loc . address
52
- } ;
53
-
54
- for ( let j = 0 ; j < ( loc . context || [ ] ) . length ; j ++ ) {
55
- const id = loc . context [ j ] . id . split ( '.' ) [ 0 ] ;
56
- properties [ id ] = loc . context [ j ] . text ;
57
-
58
- // Get country code when available
59
- if ( loc . context [ j ] . short_code ) {
60
- properties [ 'countryShortCode' ] = loc . context [ j ] . short_code ;
61
- }
62
- }
63
-
64
67
results [ i ] = {
65
68
name : loc . place_name ,
66
69
bbox : bbox ,
67
70
center : center ,
68
- properties : properties
71
+ properties : this . _getProperties ( loc )
69
72
} ;
70
73
}
71
74
}
@@ -109,7 +112,8 @@ export class Mapbox implements GeocoderAPI {
109
112
results [ i ] = {
110
113
name : loc . place_name ,
111
114
bbox : bbox ,
112
- center : center
115
+ center : center ,
116
+ properties : this . _getProperties ( loc )
113
117
} ;
114
118
}
115
119
}
You can’t perform that action at this time.
0 commit comments