Sencha touch 2 - Display current location on map

后端 未结 4 557
难免孤独
难免孤独 2021-01-07 06:27

I want to display my current location and get location coordinates to search nearby. Starting with the code below to display my location on the map, but its not working.

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-07 06:56

    Here is the code to show location current location

    var geo = Ext.create('Ext.util.Geolocation', {
     autoUpdate: false,
     listeners: {
      locationupdate: function(geo) {
         var currentLat = geo.getLatitude();
         var currentLng =  geo.getLongitude();
         var altitude = geo.getAltitude();
         var speed = geo.getSpeed();
         var heading= geo.getHeading();
      },
      locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
         if(bTimeout)
           Ext.Msg.alert('Timeout occurred',"Could not get current position");
         else 
           alert('Error occurred.');
         }
      }
     }
    });
    geo.updateLocation();
    

提交回复
热议问题