File tree Expand file tree Collapse file tree 3 files changed +22
-34
lines changed Expand file tree Collapse file tree 3 files changed +22
-34
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,7 @@ export class PlacesRestApi implements Places {
24
24
places_limit : placesLimit
25
25
}
26
26
} ) ;
27
-
28
- const data = response . data ;
29
-
30
- // augment
31
- console . log ( data . places ) ;
32
- data . places = data . places . map ( ( p ) => {
33
- p . Lat += 56.3327 + Math . random ( ) * 0.02 - 0.01 ;
34
- p . Lon += 44.0012 + Math . random ( ) * 0.02 - 0.01 ;
35
- return p ;
36
- } ) ;
37
-
38
- return data ;
27
+ return response . data ;
39
28
}
40
29
41
30
async searchImage ( areasId : number [ ] , imageFile : File , placesLimit : number = 5 ) {
@@ -49,18 +38,7 @@ export class PlacesRestApi implements Places {
49
38
areas_id : areasId
50
39
}
51
40
} ) ;
52
-
53
- const data = response . data ;
54
-
55
- // augment
56
- console . log ( data . places ) ;
57
- data . places = data . places . map ( ( p ) => {
58
- p . Lat += 56.3327 + Math . random ( ) * 0.02 - 0.01 ;
59
- p . Lon += 44.0012 + Math . random ( ) * 0.02 - 0.01 ;
60
- return p ;
61
- } ) ;
62
-
63
- return data ;
41
+ return response . data ;
64
42
}
65
43
66
44
async getPlaceInfo ( xid : string ) {
Original file line number Diff line number Diff line change @@ -8,14 +8,20 @@ export interface CategoryPrediction {
8
8
probability : number ;
9
9
}
10
10
11
+ export interface LatLon {
12
+ Lat : number ;
13
+ Lon : number ;
14
+ }
15
+
11
16
export interface ImageQueryResponse {
17
+ optimal_route : LatLon [ ] | null ;
12
18
places : PlacePrediction [ ] ;
13
19
categories : CategoryPrediction [ ] ;
14
20
}
15
21
16
22
export interface PlaceInfo {
17
23
category : string ;
18
- images : number [ ] ;
24
+ images : string [ ] ;
19
25
}
20
26
21
27
export interface PlacePrediction {
@@ -28,5 +34,6 @@ export interface PlacePrediction {
28
34
}
29
35
30
36
export interface TextQueryResponse {
37
+ optimal_route : LatLon [ ] | null ;
31
38
places : PlacePrediction [ ] ;
32
39
}
Original file line number Diff line number Diff line change 25
25
' Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
26
26
}).addTo (map );
27
27
28
- const waypoints = searchResults .res .places .map ((place ) => L .latLng (place .Lat , place .Lon ));
29
- L .Routing .control ({
30
- waypoints: waypoints ,
31
- routeWhileDragging: true ,
32
- addWaypoints: false ,
33
- createMarker : function () {
34
- return null ;
35
- } // Prevent automatic marker creation
36
- }).addTo (map );
28
+ let optimal_route = searchResults .res .optimal_route ;
29
+ if (optimal_route !== null ) {
30
+ const waypoints = optimal_route .map ((ll ) => L .latLng (ll .Lat , ll .Lon ));
31
+ L .Routing .control ({
32
+ waypoints: waypoints ,
33
+ routeWhileDragging: true ,
34
+ addWaypoints: false ,
35
+ createMarker : function () {
36
+ return null ;
37
+ } // Prevent automatic marker creation
38
+ }).addTo (map );
39
+ }
37
40
38
41
// Add markers and tooltips for each place
39
42
searchResults .res .places .forEach ((place ) => {
You can’t perform that action at this time.
0 commit comments