uniapp使用小程序地图地位功能实现方法

<map style=" 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="markers" @markertap="markertap"
      @callouttap="callouttap" :polyline="polylines" show-location :enable-traffic="true"> </map>
	data() {
			return {
				remnant:0,
				content:"",
				title:"",
				role:false,
				latitude: 39.909,
				longitude: 116.39742,
				markers: [{
						 40,
						height: 40,
						latitude: 39.9345,
						longitude: 119.61063,
						iconPath: '../../static/logo.png',
						id: 1,
						customCallout: {
							anchorX: 0,
							anchorY: 0,
							display: "BYCLICK"
						}
					},
					{
						 40,
						height: 40,
						latitude: 39.989,
						longitude: 116.39742,
						iconPath: '../../static/logo.png',
						id: 2,
						callout: {
							color: '#ffffff',
							content: '气泡内容',
							fontSize: 16,
							borderRadius: 5,
							bgColor: '#FF0000',
							padding: 20,
							textAlign: 'center',
							display: "BYCLICK"
						}
					}
				],
				polylines: [],
				markers: [], //标记点数组

  

Location() { //本地位置权限获取
                let that = this
                wx.getLocation({
                    type: 'gcj02',
                    timeout:"1000",
                    success(res) {
                        console.log(res)
                        that.latitude = res.latitude
                        that.longitude = res.longitude
                        // that.markers[0].latitude = res.latitude
                        // that.markers[0].longitude = res.longitude
                        const speed = res.speed
                        const accuracy = res.accuracy
                    }
                })

            },
原文地址:https://www.cnblogs.com/ly1368489670/p/14240564.html