< view> < buttontype = " default" bindtap = " get_location" > </ button> </ view> < view> < mapid = " my_map" latitude = " {{latitude}}" longitude = " {{longitude}}" show-location = " true"  style  =" width :  400px" > </ map> </ view> { "pages" :  [ "pages/demo01/demo01" ] , "permission" :  { "scope.userLocation" :  { "desc" :  "你的位置信息将用于小程序位置接口的效果展示"  } } 
} 
Page ( { data:  { longitude:  0 , latitude:  0 } , onLoad:  function  ( options)  { } , onReady:  function  ( )  { } , onShow:  function  ( )  { } , onHide:  function  ( )  { } , onUnload:  function  ( )  { } , onPullDownRefresh:  function  ( )  { } , onReachBottom:  function  ( )  { } , onShareAppMessage:  function  ( )  { } , get_location:  function ( )  { let  temp_this =  this ; wx. getLocation ( { type:  'wgs84' , success  ( res)  { const  latitude =  res. latitudeconst  longitude =  res. longitudeconst  speed =  res. speedconst  accuracy =  res. accuracytemp_this. setData ( { latitude:  latitude, longitude:  longitude} ) let  map_context =  wx. createMapContext ( 'my_map' ,  temp_this) ; map_context. moveToLocation ( { longitude: longitude,  latitude: latitude} ) ; } } ) ; }  } )