Cordova-plugin-googlemaps: Error catching my location google maps cordova

Created on 9 May 2018  路  6Comments  路  Source: mapsplugin/cordova-plugin-googlemaps

I'm submitting a ... (check one with "x")

  • [x] question
  • [ ] any problem or bug report
  • [ ] feature request

If you choose 'problem or bug report', please select OS: (check one with "x")

  • [ ] Android
  • [x] iOS

cordova information: (run $> cordova plugin list)

com.googlemaps.ios 2.6.0 "Google Maps SDK for iOS"
com.telerik.plugins.nativepagetransitions 0.6.5 "Native Page Transitions"
cordova-plugin-add-swift-support 1.7.1 "AddSwiftSupport"
cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-device-orientation 2.0.1 "Device Orientation"
cordova-plugin-email-composer 0.8.15 "EmailComposer"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.2.9 "cordova-plugin-googlemaps"
cordova-plugin-nativegeocoder 2.0.5 "NativeGeocoder"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-request-location-accuracy 2.2.2 "Request Location Accuracy"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.0 "SocialSharing"
cordova-sqlite-storage 2.3.1 "Cordova sqlite storage plugin"
cordova.plugins.diagnostic 3.9.2 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
onesignal-cordova-plugin 2.3.3 "OneSignal Push Notifications"

Current behavior:
captura de tela 2018-05-09 as 16 42 29

image-1

When I enter all the code performs perfectly, however at the time of picking up my location I face this image problem up.

Expected behavior:
I expect to be able to take my position and plot on the map natively.

Related code, data or error log (please format your code or data):

  loadMap() {
    // Get the map configuration information in the environment
    let mapOptions: GoogleMapOptions = environment.googleMaps.map.options;

     // This variable and declare before starting the map to be able to insert in the html the #id map and to have where to insert the map
    // On the contrary, if this variable is declared after the map creation happens, it fails and the map is not loaded
    this.setHeaderAndMessageWithZone(false, 'map_is_ready');


     // Get the html where the map will be inserted, which was released by the above variable
    let mapElement: HTMLElement = document.getElementById('map');

    // Create map and assign on map variable
    this.map = GoogleMaps.create(mapElement, mapOptions);

     // Listen to the event when the map was ready.
    // When the map is ready, it is necessary to upload information
    this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
      console.log('map iniciado e agora visivel')


      // Place Map visible
      this.map_visible = true;


       // Get the position where the user is once 
      if (!this.triggerHasPositionUser) {
         // Here I call the function where I should get my location and plot on the map
        this.getMyLocationAndCenterOnMap();
      }

      // Start listening to click events on the map
      this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe(() => {
        this.openPointInformation = false;
        this.timeDistanceBetweenMyAndPoint = null;
        this.timeDistanceBetweenPointAndBus = null;
      });
    });
  }


  // Search for user location and center on the map
  getMyLocationAndCenterOnMap() {
    this.map.getMyLocation().then((resp) => {
      // Center the camera on the user the first time
      this.map.animateCamera({
        target: resp.latLng,
        zoom: 16
      });
      this.ioUserLocationAccessTimeReal(resp.latLng);
      // Disables the trigger to pick up the user's first position.
      this.triggerHasPositionUser = true;
    });
  }

Most helpful comment

Please search on Google or past issues before asking.
https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.0.0/ReleaseNotes/v2.2.0/README.md#the-mylocation-property-has-changed

All 6 comments

Try LocationService.getMyLocation()

I do not understand, would have to do this.map.LocationService.getMyLocation();

This operation is for both ios and android, or do I have to make a condition? Now a particularity, how does this work without being declared any variable or anything? No importa, my God, I'm silly about it!

Ufa ! I saw here that it is declared. But it works for both versions.

It works so the global blue marker is not appearing, on the android when I use the this.map.getMyLocation () function it plots itself to me, how to proceed?

Please search on Google or past issues before asking.
https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.0.0/ReleaseNotes/v2.2.0/README.md#the-mylocation-property-has-changed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ebellempire picture ebellempire  路  3Comments

javi124 picture javi124  路  5Comments

lakano picture lakano  路  4Comments

bigbossmaher picture bigbossmaher  路  3Comments

Tong2203 picture Tong2203  路  5Comments