@@ -24,37 +24,41 @@ const PlacesService = () => {
24
24
} ;
25
25
26
26
function callback (
27
- results : google . maps . places . PlaceResult [ ] ,
27
+ results : google . maps . places . PlaceResult [ ] | null ,
28
28
status : google . maps . places . PlacesServiceStatus
29
29
) {
30
- if ( status === google . maps . places . PlacesServiceStatus . OK ) {
31
- for ( let index = 0 ; index < results . length ; index ++ ) {
32
- const name = results [ index ] . name ;
33
- const position = results [ index ] . geometry ?. location ;
34
- const openingHours = results [ index ] . opening_hours ;
30
+ if ( status !== google . maps . places . PlacesServiceStatus . OK || ! results ) {
31
+ console . error ( status ) ;
35
32
36
- const isOpenStatus = openingHours ? 'open' : 'closed' ;
33
+ return ;
34
+ }
37
35
38
- if ( ! map || ! position ) {
39
- return ;
40
- }
36
+ for ( let index = 0 ; index < results . length ; index ++ ) {
37
+ const name = results [ index ] . name ;
38
+ const position = results [ index ] . geometry ?. location ;
39
+ const openingHours = results [ index ] . opening_hours ;
41
40
42
- const marker = new google . maps . Marker ( {
43
- map,
44
- position
45
- } ) ;
41
+ const isOpenStatus = openingHours ? 'open' : 'closed' ;
46
42
47
- markers . push ( marker ) ;
43
+ if ( ! map || ! position ) {
44
+ return ;
45
+ }
48
46
49
- map . fitBounds ( bounds . extend ( position ) ) ;
47
+ const marker = new google . maps . Marker ( {
48
+ map,
49
+ position
50
+ } ) ;
50
51
51
- const infowindow = new google . maps . InfoWindow ( {
52
- position,
53
- content : `<b>${ name } </b> is ${ isOpenStatus } `
54
- } ) ;
52
+ markers . push ( marker ) ;
55
53
56
- infowindow . open ( map , marker ) ;
57
- }
54
+ map . fitBounds ( bounds . extend ( position ) ) ;
55
+
56
+ const infowindow = new google . maps . InfoWindow ( {
57
+ position,
58
+ content : `<b>${ name } </b> is ${ isOpenStatus } `
59
+ } ) ;
60
+
61
+ infowindow . open ( map , marker ) ;
58
62
}
59
63
}
60
64
0 commit comments