微信小程序使用高德地图(amap)实现检索定位附近周边的POI功能示例

本文展示了如何在微信小程序中使用高德地图(amap)API实现定位和搜索附近地点(POI)的功能。通过示例代码详细说明了地图组件的样式设置、事件监听以及获取用户位置和显示搜索结果的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

width: 100%;

overflow: hidden;

position: absolute;

top: 100rpx;

bottom: 100rpx;

left: 0;

right: 0;

}

.map {

width: 100%;

height: 100%;

}

.map_text {

width: 95%;

height:auto;

position: absolute;

left: 0;

bottom: 0;

background: #fff;

padding: 2.5%;

overflow: hidden;

}

.map_text .navigation {

position: absolute;

right: 20rpx;

top: 35rpx;

}

.map_text .name {

line-height: 60rpx;

font-size: 30rpx;

padding-left: 10rpx;

}

.map_text .desc {

width: 100%;

display: flex;

line-height: 35rpx;

}

.map_text .desc .address {

width: calc(100% - 120rpx);

width: -webkit-calc(100% - 120rpx);

width: -moz-calc(100% - 120rpx);

font-size: 25rpx;

color: #666;

overflow: hidden;

text-overflow: ellipsis;

display: -webkit-box;

-webkit-line-clamp: 2;

-webkit-box-orient: vertical;

}

.odd_row {

color: #666;

padding: 10rpx 30rpx;

height: 70rpx;

line-height: 70rpx;

background: rgba(236, 255, 255, 0.8);

cursor: pointer;

}

.even_row {

color: #666;

padding: 10rpx 30rpx;

height: 70rpx;

line-height: 70rpx;

background: rgba(241, 255, 222, 0.8);

cursor: pointer;

}

index.js

//引入高德SDK

var amapFile = require(‘…/…/libs/amap-wx.js’);

var key = “高德地图的key”;

var markersData = [];

Page({

/**

  • 页面的初始数据

*/

data: {

markers: [],

latitude: ‘’,

longitude: ‘’,

textData: {},

city: ‘’,

keywords: ‘加油站’,

mapshow:true,

maptextshow: false,

tipshow:false,

tips: {},

isIos: false,

currentLocation:{},

range:‘’,

},

makertap: function (e) {

var id = e.markerId;

var that = this;

that.showMarkerInfo(markersData, id);

that.changeMarkerColor(markersData, id);

},

/**

  • 生命周期函数–监听页面加载

*/

onLoad: function (e) {

v

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值