微信小程序 地图map实例详解
wxml:
rush:xml;">
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">
js:
rush:js;">
//获取应用实例
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,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
})
}
})
}
})
效果图:
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。