This article example shares the specific implementation code used by the WeChat applet map for your reference. The specific content is as follows The following code is the main code snippet <!-- Map section --> <!-- enable-traffic Display traffic conditions --> <view class="map_container"> <map id='customerMap' class="map" :longitude='longitude' :latitude='latitude' :scale='scale' :markers='markers' :controls="controls" show-location @markertap="markertap" @updated="updatedmap" @controltap='bindcontroltap'></map> </view> data(){ return { latitude:23.140962248, longitude:113.305301124, scale:12, markers:[ {id: '', latitude: 23.140962248, longitude: 113.305301124, iconPath: '../static/select-dw.png', //Current location icon path width: 25, height: 39, }, { latitude: 23.129742, longitude: 113.26754, iconPath: '../static/mark.png', //Customer icon path width: 28, height: 28, label: { content: 'Zhan Junjun', textAlign: 'center', fontSize: 12 } }] } }, onReady() { this.mapCtx = wx.createMapContext('customerMap') }, methods:{ // Click on the marker point markertap(e) { let { markerId } = e.detail; let item = this.markers.find(v => v.id === markerId); console.log('item', item) uni.openLocation({ latitude: Number(item.latitude), longitude: Number(item.longitude), name: item.label.content, address: item.address, success: function() { console.log('success'); } }); }, // When the map is loaded, trigger updatedmap() { this.mapUpdated = true; console.log('execution') this.includePoints(); //All customers are displayed in the view}, // Make the marker point visible in the map includePoints() { const that = this const points = [{ latitude: that.latitude, longitude: that.longitude }]; this.markers.forEach(item => { const obi = { latitude: item.latitude, longitude: item.longitude } points.push(obi) }) this.mapCtx.includePoints({ padding: [80, 50, 80, 50], points }) }, } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Example of using MRG_MyISAM (MERGE) to implement query after partitioning in MySQL
>>: 8 powerful techniques for HTML web page creation
This article describes the mysql show operation w...
Install fastdfs on Docker Mount directory -v /e/f...
1. Download docker online yum install -y epel-rel...
Scary, isn't it! Translation in the picture: ...
Vertical table Vertical table splitting means spl...
MySQL 8.0.19 supports locking the account after e...
Table of contents How to create a Pod? kubectl to...
This article aims to use the clearest structure t...
1. Download the pip installation package accordin...
Table of contents Add traffic function to github+...
Before you begin Have a cloud server, mine is Ten...
Table of contents Vue3 encapsulation message prom...
Drop-down box, text field, file field The upper p...
I used the label tag when I was doing something re...
Table of contents 1. What is copy_{to,from}_user(...