-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of map internal state
- Loading branch information
1 parent
91177ff
commit 9865de6
Showing
6 changed files
with
93 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { catchError, Observable, tap, throwError } from 'rxjs'; | ||
import { NGXLogger } from 'ngx-logger'; | ||
|
||
@Injectable() | ||
export class GeoService { | ||
constructor(private readonly log: NGXLogger) {} | ||
|
||
myCurrentLocation() { | ||
return new Observable<GeolocationCoordinates>(observer => { | ||
window.navigator.geolocation.getCurrentPosition( | ||
position => { | ||
observer.next(position.coords); | ||
observer.complete(); | ||
}, | ||
err => observer.error(err), | ||
{ enableHighAccuracy: false, timeout: 5000 } | ||
); | ||
}).pipe( | ||
tap(d => { | ||
this.log.debug('Got your location', d); | ||
}), | ||
// it will be invoked if our source observable emits an error. | ||
catchError(error => { | ||
this.log.error('failed to get your location', error); | ||
return throwError(() => error); | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { MapService } from './map.service'; | ||
import { GeoService } from './geo.service'; | ||
|
||
@NgModule({ | ||
providers: [MapService] | ||
providers: [GeoService, MapService] | ||
}) | ||
export class MapModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ $tertiary: #fff; | |
$accent: #404040; | ||
$accent-dark: #463A05FF; | ||
$accent-bright: #ffd617; | ||
$dark-matter-bg: #262627; |