实现高德地图签到签退(uniapp)

项目场景:

用uniapp 实现签到签退(使用高德的api)


问题描述

提示:这里描述项目中遇到的问题:

例如:使用uniapp 自带的组件不能实现点击地图 再签退


提示思路:

提示:使用uniapp (写入2个script,第一个script,放自己本身的方法,第二个script放加载地图的方法)


解决方案:

<view  id="amap" class="amap" :prop="locationInfo"  :change:prop="amap.updateEcharts" @click="amap.onClick" ></view>

//获取经纬度

  async    getAddress(){
      let _this=this;
        return new Promise((resolve, reject) => {
           uni.getLocation({
                type: 'wgs84',
                geocode:true,
                success: function(res) {
                    _this.lng= [res.longitude,res.latitude]
                    resolve(_this.lng)        
                }
            });
            })
        },

    getPoe(){
            getInfo().then(res=>{
                this.sginPro.roleName=res.data.roles[0].roleName
                this.sginPro.roleId =res.data.roles[0].id
            })
        },

//第二个script

     updateEcharts(newValue, oldValue, ownerInstance, instance) {
               // console.log(newValue,oldValue,'00000')
                    this.lng=newValue.lng
                    this.lat=newValue.lat
                    // this.initMarkers()
            },

     getAddress(){
                let _this=this;
                var geoCoder;
                this.map.plugin(['AMap.Geocoder'],function(){
                    geoCoder = new AMap.Geocoder({
                        city: ""//城市,默认:“全国”
                    });
                    var lnglatXY = _this.lat !== ''?[_this.lng,_this.lat]:''; // 地图上所标点的坐标
                    geoCoder.getAddress(lnglatXY, function(status, result) {
                        _this.sginPro.signInAddress =  result.regeocode.formattedAddress;
                        _this.onClick(null,_this.ownerInstance,_this.sginPro.signInAddress)
                        _this.$ownerInstance.callMethod('onViewClick', _this.sginPro.signInAddress)
                       
                    })
                    
                })
            },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值