当前位置:网站首页>微信小程序 实现位置地图显示,引入map地图,不含导航
微信小程序 实现位置地图显示,引入map地图,不含导航
2022-07-27 15:48:00 【星星也会数人类嘛】
wxml:
<view class="mapView" bindtap="mapViewClick" data-name="{
{item.name}}" >
<i class="fa fa-map-marker" aria-hidden="true"></i>
{
{item.address}}
</view>
js:
/** * 地图点击 * @param {*} event */
mapViewClick: function(event){
wx.navigateTo({
url: '/pages/venue/venue?name='+event.target.dataset.name,
})
}
venue页面:
<cu-custom bgColor="bg-gradual-green" isBack="{
{true}}">
<view slot="backText">返回</view>
<view slot="content">{
{addressName}}</view>
</cu-custom>
<view class='maps'>
<map id="map" longitude="{
{longt}}" latitude="{
{lat}}" scale="16" controls="{
{controls}}" bindcontroltap="controltap" markers="{
{markers}}" bindmarkertap="markertap" polyline="{
{polyline}}" bindregionchange="regionchange" show-location show-compass="true" ></map>
</view>
venue js:
Page({
data: {
inputFocus: false,
key:"",
searchRes:[],
longt: 123.419902,
lat: 41.852319,
markers: [],
polyline: [{
points: [{
longitude: 113.3245211,
latitude: 23.10229
}, {
longitude: 123.324520,
latitude: 23.21229
}],
color: 'red',
width: 3,
dottedLine: true
}]
},
/** * 页面加载 * @param {*} options */
onLoad: function(options){
if(options.name == "友谊"){
var arr = [{
iconPath: '../images/markMapPng.png',
id: 1,
latitude: 41.852491,
longitude: 123.419383,
width: 30,
height: 30,
title: '辽宁宾馆'
}]
this.setData({
markers: arr,
addressName: '友谊'
})
} else{
var arr = [{
iconPath: '../images/markMapPng.png', // 这个是显示位置的图标icon,自己下个图片什么的
id: 2,
latitude: 41.734353,
longitude: 123.505202,
width: 30,
height: 30,
title: '浑南'
}]
this.setData({
markers: arr,
addressName: '浑南',
longt:123.505202,
lat: 41.734353
})
}
}
})
wxss:
#searchDiv{
top: 5px;
width: 80%;
margin: 0 10%;
background: rgba(255, 255, 255, 0.9);
border-radius: 5px;
box-shadow: 0px 0px 5px #E0E3E4;
position: fixed;
}
#searchDiv .text,#searchDiv .search_input,#searchDiv .search_icon{
height: 50px;
line-height: 50px;
}
#searchDiv .text{
margin-left: 20px;
}
#searchDiv .search_input{
margin-left: 20px;
/* 使视觉上和text保持一致 */
margin-top: -50px;
}
#searchDiv .search_icon{
display: inline-block;
top: 0;
position: absolute;
right: 0px;
}
#searchDiv .search_icon cover-image{
width: 30px;
height: 30px;
padding: 10px;
}
#map{
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}

点击后显示位置:
边栏推荐
- numpy数组矩阵操作
- Understanding service governance in distributed development
- [single chip microcomputer] 2.1 hardware composition of AT89S52 single chip microcomputer
- Gree "not cool": the giant lawsuit ended and was reduced by large dealers. Is it too late for the new battlefield of air conditioning?
- (2)融合cbam的two-stream项目搭建----数据准备
- 步 IE 后尘,Firefox 的衰落成必然?
- 密集光流提取dense_flow理解
- What should we pay attention to when choosing the LED display screen of the stadium
- Zhengzhou University database course resource description
- 帮扶、提振、担当,第六届土巴兔718全民家装节的新价值和意义
猜你喜欢

Why is domestic Xinguan oral medicine a drug for the treatment of AIDS

Microsoft silently donated $10000 to curl, which was not notified until half a year later

SAP UI5 FileUploader 使用的隐藏 iframe 和 form 元素的设计明细

numpy数组矩阵操作

树莓派驱动代码的编译和测试

SAP UI5 FileUploader 的本地文件上传技术实现分享

如何限制root远程登入,使普通用户拥有root权限

What should we pay attention to when choosing the LED display screen of the stadium

Gree "not cool": the giant lawsuit ended and was reduced by large dealers. Is it too late for the new battlefield of air conditioning?

可口可乐的首要挑战,不是元气森林
随机推荐
SVM+Surf+K-means花朵分类(Matlab)
Switch and router technology-02-working principle of Ethernet switch
【数据库系统概论(王珊)】第1章——绪论
wallys/DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power.
Initial polymorphism
苹果官网罕见打折,iPhone13全系优惠600元;国际象棋机器人弄伤对弈儿童手指;国内Go语言爱好者发起新编程语言|极客头条...
成本高、落地难、见效慢,开源安全怎么办?
数据库超话(一)
Could not obtain transaction-synchronized Session for current thread
Can deep learning overturn video codec? The first prize winner of the National Technological Invention Award nags you in the little red book
Database hyperphone (I)
详解二叉树之堆
【单片机】2.3 AT89S52的CPU
Explain the pile of binary trees in detail
详解分布式系统的幂等
Functions of C language
With the arrival of large displacement hard core products, can the tank brand break through the ceiling of its own brand?
灵魂一问:为什么ES比MySQL更适合复杂条件搜索?
SAP UI5 FileUploader 的隐藏 iframe 设计明细
关于 SAP UI5 应用 ui5.yaml 里的 paths 映射问题