小程序 | 微信小程序中使用位置API打开地图

小程序 | 微信小程序中使用位置API打开地图

一、效果展示

小程序 | 微信小程序中使用位置API打开地图_第1张图片
小程序 | 微信小程序中使用位置API打开地图_第2张图片


二、代码实现

使用微信内置地图查看位置,调用wx.openLocationAPI,具体内容可以查看微信官方文档。

// js 
let Info = {
	Name : '天安门广场',
	Address : '北京市东城区东长安街天安门广场',
	latitudu : '39.90374',
	longitude : '116.397827',
}

Page({
	
	/**
	 * 页面初始数据
	 */
	data : {
		Info : Info,
	},

	/**
	 * 导航按钮点击事件
	 */
    addressNavigation : function() {
        wx.openLocation({
            type: "gcj02",
            latitude: Number(this.data.Info.latitude),
            longitude: Number(this.data.Info.longitude),
            scale: 15,
            name: this.data.Info.Name,
            address: this.data.Info.Address,
            success: (result)=>{},
            fail: ()=>{},
            complete: ()=>{}
        });
    },
    
})


你可能感兴趣的:(微信小程序,小程序,微信)