Micro letter applet - Get current location

Permission to increase property configuration in app.json inside (game must be configured in game.json in):

"permission" : {
     "scope.userLocation" : {
       "desc": "Your location information will be used to map display" 
    } 
  }

index.wxml:

<view>
  <button bindtap="map">定位</button>
</view>

index.js:

Page ({ 
  Data: { 

  }, 
  Map: function () { 
    wx.getLocation ({ 
      type: 'gcj02', // return the latitude and longitude can be used wx.openLocation 
      Success: function (RES) {
         var Latitude = res.latitude
         var = longitude res.longitude 
        wx.openLocation ({ 
          Latitude: Latitude, 
          longitude: longitude, 
          Scale: 28 
        }) 
      } 
    }) 
  } 
})

 

Guess you like

Origin www.cnblogs.com/shirliey/p/12020706.html