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
In the previous article, we introduced how to for...
Use runlike to view the docker run startup parame...
Table of contents What is LocalStorage What is Se...
There are two types: (different browsers) 1. Avail...
1. Back button Use history.back() to create a bro...
1. In Windows system, many software installations...
Question: Is the origin server unable to find a r...
The following code introduces Chrome's monito...
Preface This article uses pdo's preprocessing...
Table of contents Overview Static type checking C...
Preface Note: The test database version is MySQL ...
I have previously introduced to you the configura...
If there is an <input type="image">...
1. Check whether event is enabled show variables ...
What is bond NIC bond is a technology that is com...