How to use @ionic-native/google-maps - 10 common examples

To help you get started, we’ve selected a few @ionic-native/google-maps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / Ionic-MFP-App / IonicMobileApp / src / pages / report-new / report-new.ts View on Github external
createMap() {
    // TODO need to store/retrieve prevLoc in app preferences/local storage
    let prevLoc = new LatLng(13.0768342, 77.7886087);
    let mapOptions: GoogleMapOptions = {
      camera: {
        target: prevLoc,
        zoom: 15,
        tilt: 10
      }
    };
    this.map = GoogleMaps.create('map', mapOptions);
    this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
      console.log('--> ReportNewPage: Map is Ready To Use');
      this.mapReady = true;
      // https://stackoverflow.com/questions/4537164/google-maps-v3-set-single-marker-point-on-map-click
      this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe( event => {
        this.location = event[0];
        console.log('--> ReportNewPage: User clicked location = ' + event[0]);
        this.map.clear();
        this.map.addMarker({
          title: 'Selected location',
          position: event[0]
        }).then((marker: Marker) => {
          this.autoFillAddress();
          marker.showInfoWindow();
        });
      });
github IBM / Ionic-MFP-App / IonicMobileApp / src / pages / report-new / report-new.ts View on Github external
createMap() {
    // TODO need to store/retrieve prevLoc in app preferences/local storage
    let prevLoc = new LatLng(13.0768342, 77.7886087);
    let mapOptions: GoogleMapOptions = {
      camera: {
        target: prevLoc,
        zoom: 15,
        tilt: 10
      }
    };
    this.map = GoogleMaps.create('map', mapOptions);
    this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
      console.log('--> ReportNewPage: Map is Ready To Use');
      this.mapReady = true;
      // https://stackoverflow.com/questions/4537164/google-maps-v3-set-single-marker-point-on-map-click
      this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe( event => {
        this.location = event[0];
        console.log('--> ReportNewPage: User clicked location = ' + event[0]);
        this.map.clear();
        this.map.addMarker({
          title: 'Selected location',
          position: event[0]
        }).then((marker: Marker) => {
          this.autoFillAddress();
          marker.showInfoWindow();
        });
      });
    });
github UCL-INGI / StudUCLouvain / src / providers / map-services / map-service.ts View on Github external
//let latLng = new LatLng(position.coords.latitude, position.coords.longitude);
          let latLng = position.latLng;
          let mapOptions = {
            center: latLng,
            zoom: 15,
            mapTypeId: GoogleMapsMapTypeId.ROADMAP
          }
          // create CameraPosition
          let camPos: CameraPosition = {
            target: latLng,
            zoom: 15
          };
          //this.map = new GoogleMap(this.mapElement, mapOptions);
          this.map = GoogleMaps.create(this.mapElement, mapOptions);
          this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
            console.log('Map is ready!');
            this.map.moveCamera(camPos);
            resolve(true);
          });
        }, (error) => {
          console.log("Map error initDeviceMap : " + error);
github IBM / Ionic-MFP-App / IonicMobileApp / src / pages / report-new / report-new.ts View on Github external
createMap() {
    // TODO need to store/retrieve prevLoc in app preferences/local storage
    let prevLoc = new LatLng(13.0768342, 77.7886087);
    let mapOptions: GoogleMapOptions = {
      camera: {
        target: prevLoc,
        zoom: 15,
        tilt: 10
      }
    };
    this.map = GoogleMaps.create('map', mapOptions);
    this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
      console.log('--> ReportNewPage: Map is Ready To Use');
      this.mapReady = true;
      // https://stackoverflow.com/questions/4537164/google-maps-v3-set-single-marker-point-on-map-click
      this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe( event => {
        this.location = event[0];
        console.log('--> ReportNewPage: User clicked location = ' + event[0]);
        this.map.clear();
github IBM / Ionic-MFP-App / IonicMobileApp / src / pages / report-new / report-new.ts View on Github external
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
      console.log('--> ReportNewPage: Map is Ready To Use');
      this.mapReady = true;
      // https://stackoverflow.com/questions/4537164/google-maps-v3-set-single-marker-point-on-map-click
      this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe( event => {
        this.location = event[0];
        console.log('--> ReportNewPage: User clicked location = ' + event[0]);
        this.map.clear();
        this.map.addMarker({
          title: 'Selected location',
          position: event[0]
        }).then((marker: Marker) => {
          this.autoFillAddress();
          marker.showInfoWindow();
        });
      });
    });
  }
github UCL-INGI / StudUCLouvain / src / providers / map-services / map-service.ts View on Github external
(position) => {
          console.log("initDeviceMap - geolocation answered");
          this.userLocation = new MapLocation( "Ma Position",
                                      "",
                                      String(position.latLng.lat),
                                      String(position.latLng.lng),
                                      "MYPOS");

          //let latLng = new LatLng(position.coords.latitude, position.coords.longitude);
          let latLng = position.latLng;
          let mapOptions = {
            center: latLng,
            zoom: 15,
            mapTypeId: GoogleMapsMapTypeId.ROADMAP
          }
          // create CameraPosition
          let camPos: CameraPosition = {
            target: latLng,
            zoom: 15
          };
          //this.map = new GoogleMap(this.mapElement, mapOptions);
          this.map = GoogleMaps.create(this.mapElement, mapOptions);
          this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
            console.log('Map is ready!');
            this.map.moveCamera(camPos);
            resolve(true);
          });
        }, (error) => {
          console.log("Map error initDeviceMap : " + error);
github UCL-INGI / StudUCLouvain / src / providers / map-services / map-service.ts View on Github external
return new Promise((resolve, reject) => {
      LocationService.getMyLocation().then(
        (position) => {
          console.log("initDeviceMap - geolocation answered");
          this.userLocation = new MapLocation( "Ma Position",
                                      "",
                                      String(position.latLng.lat),
                                      String(position.latLng.lng),
                                      "MYPOS");

          //let latLng = new LatLng(position.coords.latitude, position.coords.longitude);
          let latLng = position.latLng;
          let mapOptions = {
            center: latLng,
            zoom: 15,
            mapTypeId: GoogleMapsMapTypeId.ROADMAP
          }
          // create CameraPosition
github longzheng / mypal-ionic / src / pages / topup-map / topup-map.ts View on Github external
(locations: any) => {
            // process all markers
            for (var i = 0; i < locations.length; i++) {
              let location = locations[i];

              // create new marker
              let markerOptions: MarkerOptions = {
                position: new LatLng(location.outlet_latitude, location.outlet_longitude),
                title: location.outlet_business,
                snippet: `${location.outlet_name}, ${location.outlet_suburb}, ${location.outlet_postcode}`+
                `\r\nMonday: ${location.outlet_business_hour_mon !== null ? location.outlet_business_hour_mon : "N/A"}`+
                `\r\nTuesday: ${location.outlet_business_hour_tue !== null ? location.outlet_business_hour_tue : "N/A"}`+
                `\r\nWednesday: ${location.outlet_business_hour_wed !== null ? location.outlet_business_hour_wed : "N/A"}`+
                `\r\nThursday: ${location.outlet_business_hour_thur !== null ? location.outlet_business_hour_thur : "N/A"}`+
                `\r\nFriday: ${location.outlet_business_hour_fri !== null ? location.outlet_business_hour_fri : "N/A"}`+
                `\r\nSaturday: ${location.outlet_business_hour_sat !== null ? location.outlet_business_hour_sat : "N/A"}`+
                `\r\nSunday: ${location.outlet_business_hour_sun !== null ? location.outlet_business_hour_sun : "N/A"}`
              };
              // add marker to list to be added
              this.map.addMarker(markerOptions);
            }
            loader.dismiss();
          }
        , error => {
github bharathirajatut / ionic4 / google-map-example / home.page.ts View on Github external
loadMap() {

    // This code is necessary for browser
    Environment.setEnv({
      'API_KEY_FOR_BROWSER_RELEASE': 'API-KEY',
      'API_KEY_FOR_BROWSER_DEBUG': 'API-KEY'
    });

    let mapOptions: GoogleMapOptions = {
      camera: {
         target: {
          lat: 13.0380523,
          lng: 80.21371
         },
         zoom: 18,
         tilt: 30
       }
    };

    this.map = GoogleMaps.create('map', mapOptions);
github zyra / ionic-native-playground / src / components / google-map / google-map.ts View on Github external
.then(() => {
        this.map = this.googleMaps.create(this.mapContainer, this.options);

        this.map.one(GoogleMapsEvent.MAP_READY)
          .then(() => {
            console.log('Map ready fired', this.map);

            this.mapReady.emit(this.map);
            this.isInit = true;
          });

        this.map.on(GoogleMapsEvent.MAP_CLICK)
          .subscribe(data => this.mapClick.emit(data));

      });