import { Injectable } from '@angular/core' ; import { Observable , Observer } from 'rxjs' ; import { IJson } from './util' ; /**
 *  service for navigator.geolocation methods
 */ @ Injectable ( ) export class NavigatorGeolocation { getCurrentPosition ( geoLocationOptions ? ) { geoLocationOptions = geoLocationOptions || { timeout : 5000 } ; return new Observable < any > ( ( responseObserver ) => { if ( navigator . geolocation ) { navigator . geolocation . getCurrentPosition ( ( position ) => { responseObserver . next ( position ) ; responseObserver . complete ( ) ; } , ( evt ) => responseObserver . error ( evt ) , geoLocationOptions ) ; } else { responseObserver . error ( 'Browser Geolocation service failed.' ) ; } } ) ; } }