import { Platform } from 'ionic-angular';
import {
LocationService,
GoogleMap,
GoogleMapOptions,
MyLocation
} from '@ionic-native/google-maps';
export class MapPage {
map: GoogleMap;
constructor(private platform: Platform) {
this.platform.ready().then(()=> {
this.loadMap();
});
}
loadmap() {
LocationService.getMyLocation().then((myLocation: MyLocation) => {
let options: GoogleMapOptions = {
camera: {
target: myLocation.latLng
}
};
this.map = GoogleMaps.create('map_canvas', options);
});
}
}
Get the current device location without map.
Params | Type | Details |
---|---|---|
options | MyLocationOptions | (optional)Initial option |
➡️ Promise<MyLocation>
Return true if application has geolocation
permission.
This method works on Android
, iOS
, Browser on Chrome/FireFox
correctly.
Other browsers (Safari
, Opera
, Microsoft Edge
,...etc) do not work.
➡️ Promise<boolean>