Skip to content

Latest commit

 

History

History
66 lines (50 loc) · 1.22 KB

File metadata and controls

66 lines (50 loc) · 1.22 KB

LocationService class

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);

    });
  }
}

Static method

getMyLocation(options?)

Get the current device location without map.

Params Type Details
options MyLocationOptions (optional)Initial option

➡️ Promise<MyLocation>

hasPermission()

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>