源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

微信小程序 地图map实例详解

  • 时间:2022-12-13 13:28 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:微信小程序 地图map实例详解
[b]微信小程序 地图map实例详解[/b] [b]wxml:[/b]
class="button" bindtap="getlocation" style="margin-top:30px" markers="{{markers}}">定位 
 longitude="{{longitude}}" latitude="{{latitude}}" markers="{{markers}}" covers="{{covers}}" 
style="width: 100%; height: 300px;margin-top:30px">
[b]js:[/b]
//获取应用实例 
var app = getApp()
Page({
data: {
latitude: 0,//纬度 
longitude: 0,//经度 
speed: 0,//速度 
accuracy: 16,//位置精准度 
markers: [],
covers: [],
},
onLoad: function () {
},
getlocation: function () {
var markers = [{
latitude: 28.211400,
longitude: 112.914250,
name: '喜地大厦',
desc: '我的位置'
}]
var covers = [{
latitude: 28.211400,
longitude: 112.914250,
iconPath: '/image/ic_position.png',
rotate: 0
}]
this.setData({
longitude: 112.914250,
latitude: 28.211400,
markers: markers,
covers: covers,
})
wx.getLocation({
type: 'gcj02',
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
var speed = res.speed
var accuracy = res.accuracy
console.log("latitude:" + latitude)
console.log("longitude:" + longitude)
console.log("speed:" + speed)
console.log("accuracy:" + accuracy)
wx.openLocation({
latitude: latitude,
longitude: longitude,
scale: 28
})
}
})
}
})
[b]效果图: [/b] [img]http://files.jb51.net/file_images/article/201706/201767162006960.png?201757162037[/img] [img]http://files.jb51.net/file_images/article/201706/201767162046244.png?201757162058[/img] 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部