1、腾讯地图注册,获取秘钥
2、下载微信小程序JavaScriptSDK,微信小程序JavaScriptSDK v1.2
3、小程序引入并使用,下面是搜索地点显示目标地图代码
js代码
// 引入wx-jssdk
import QQMapWX from '../../../utils/qqmap-wx-jssdk.min.js';
var qqmapsdk;
Page({
data:{
},
onLoad: function(){
var _this = this,
searchName = '海淀黄庄地铁站';
qqmapsdk = new QQMapWX({
key: '秘钥'
});
qqmapsdk.geocoder({
address: '北京市' + searchName,
success: function (res) {
console.log('suc', res);
// res.result.location 为地点的经纬度
var point = res.result.location;
_this.setData({
point: point ,
markers: [{
iconPath: '/img/location.png',
id: 0,
latitude: point.lat,
longitude: point.lng,
title: searchName,
width: 30,
height: 30,
callout: {