File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change 1
1
import AbstractProvider , {
2
+ BoundsTuple ,
2
3
EndpointArgument ,
3
4
LatLng ,
4
5
ParseArgument ,
@@ -94,16 +95,22 @@ export default class OpenCageProvider extends AbstractProvider<
94
95
}
95
96
96
97
parse ( response : ParseArgument < RequestResult > ) : SearchResult < RawResult > [ ] {
97
- return response . data . results . map ( ( r ) => ( {
98
- x : r . geometry . lng ,
99
- y : r . geometry . lat ,
100
- label : r . formatted ,
101
- bounds : [
102
- [ r . bounds . southwest . lat , r . bounds . southwest . lng ] , // s, w
103
- [ r . bounds . northeast . lat , r . bounds . northeast . lng ] , // n, e
104
- ] ,
105
- raw : r ,
106
- } ) ) ;
98
+ return response . data . results . map ( ( r ) => {
99
+ let bounds = null ;
100
+ if ( r . bounds ) {
101
+ bounds = [
102
+ [ r . bounds . southwest . lat , r . bounds . southwest . lng ] , // s, w
103
+ [ r . bounds . northeast . lat , r . bounds . northeast . lng ] , // n, e
104
+ ] as BoundsTuple ;
105
+ }
106
+ return {
107
+ x : r . geometry . lng ,
108
+ y : r . geometry . lat ,
109
+ label : r . formatted ,
110
+ bounds,
111
+ raw : r ,
112
+ } ;
113
+ } ) ;
107
114
}
108
115
109
116
async search ( options : SearchArgument ) : Promise < SearchResult < RawResult > [ ] > {
You canβt perform that action at this time.
0 commit comments