Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
doMap() {
if( plugin.google ) {
let mapDiv = document.getElementById("google-map");
// Do this when checkin button clicked
Geolocation.getCurrentPosition().then((position) => {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
let pos = new plugin.google.maps.LatLng(latitude,longitude);
// Initialize the map plugin
let map = plugin.google.maps.Map.getMap(mapDiv, {
'camera': {
'latLng': pos,
'zoom': 10
}
});
map.addMarker({
'position': pos,
let locationObs = Observable.create(observable => {
Geolocation.getCurrentPosition(options)
.then(resp => {
let lat = resp.coords.latitude;
let lng = resp.coords.longitude;
let location = new google.maps.LatLng(lat, lng);
console.log('Geolocation: ' + location);
observable.next(location);
loading.dismiss();
},
(err) => {
console.log('Geolocation err: ' + err);
loading.dismiss();
})
getLocalWeather() {
let locOptions = { 'maximumAge': 3000, 'timeout': 5000, 'enableHighAccuracy': true };
Geolocation.getCurrentPosition(locOptions).then(pos => {
//Store our location object for later use
this.currentLoc = { 'lat': pos.coords.latitude, 'long': pos.coords.longitude };
//and ask for the weather for the current location
this.showCurrent();
}).catch(e => {
console.error('Unable to determine current location');
if (e) {
console.log('%s: %s', e.code, e.message);
console.dir(e);
}
})
}
token => {
Geolocation.getCurrentPosition().then((resp) => {
let url = this.BASE_URL + 'action';
let body = JSON.stringify({'access_token': token, 'action': action,
'target': target, 'lat': resp.coords.latitude, 'lng': resp.coords.longitude});
let headers = new Headers({'Content-Type': 'application/json'});
this.http.post(url, body, {headers: headers})
.map(res => res.json())
.subscribe(data => {
console.log(data.msg);
resolve();
}, error => {
reject();
});
});
}
);
let locationObs = Observable.create(observable => {
Geolocation.getCurrentPosition(options)
.then(resp => {
let lat = resp.coords.latitude;
let lng = resp.coords.longitude;
let location = new google.maps.LatLng(lat, lng);
console.log('Geolocation: ' + location);
observable.next(location);
loading.dismiss();
},
(err) => {
console.log('Geolocation err: ' + err);
loading.dismiss();
})
return new Promise((resolve, reject) => {
return Geolocation.getCurrentPosition().then((resp) => {
this.locationLoading = false;
resolve(resp.coords);
}).catch((error) => {
this.locationLoading = false;
this.resetCoords();
});
});
}
this.platform.ready().then(() => {
Geolocation.getCurrentPosition().then(
res => this.updateOutput(res),
err => this.updateOutput(err, true)
);
});
}
.create((observer: Observer) => {
Geolocation.getCurrentPosition(options)
.then(pos => {
observer.next(pos.coords);
observer.complete();
}).catch(error => {
observer.error(error);
observer.complete();
});
});
showDirections(destination) {
this.map.clearRoutes();
Geolocation.getCurrentPosition().then(position => {
let start = {
latitude: position.coords.latitude,
longitude: position.coords.longitude
};
this.map.navigate(start, destination);
})
}
}