天意之都
天意之都
  • 发布:2021-04-15 17:24
  • 更新:2021-04-15 17:49
  • 阅读:604

修改地图圆的半径 没有效果

分类:uni-app

第一个方法设置圆的半径为1生效,第二个方法设置半径为600不生效。

              getCircles:function(){  
                let that = this;  
                uni.chooseLocation({  
                    success: function (res) {  
                        console.log('位置名称:' + res.name);  
                        console.log('详细地址:' + res.address);  
                        console.log('纬度:' + res.latitude);  
                        console.log('经度:' + res.longitude);  
                        testMarkers[0].latitude=res.latitude;  
                        testMarkers[0].longitude=res.longitude;  
                        testCircles[0].latitude=res.latitude;  
                        testCircles[0].longitude=res.longitude;  
                        testCircles[0].radius=1;  
                        that.markers = testMarkers;  
                        that.circles = testCircles;  
                    }  
                });  
                console.log(that.circles)  
            },  
            getCircles2:function(){  
                console.log(this.circles)  
                this.circles = [];  
                                let that = this;  
                setTimeout(function(){    
                    testCircles[0].radius=600;  
                    that .circles = testCircles;  
                    // _self.circles[0].latitude;    
                    // _self.circles[0].longitude    
                },1000)  
            }
2021-04-15 17:24 负责人:无 分享
已邀请:
天意之都

天意之都 (作者)

去除定时直接写或者去除this.circles=[] 接不生效.

DCloud_Android_ST

DCloud_Android_ST

完整示例提供一下

天意之都

天意之都 (作者)

<template>  
    <view class="content">  
        <view style="width: 100%;" class="topView">  
            <view class="baby" @click="getCircles">围栏</view>  
            <view class="baby" @click="getCircles2">更改坐标</view>  
        </view>  
        <view>  
        <map id="map" scale="14" :circles="circles" :markers="markers"  
        :style="{height: nowMapIndex ? nintyPercentScreenHeight : seventyPercentScreenHeight,width:'750rpx'}">  

            </map>  
        </view>  
    </view>  
</template>  

<script>  
    var testCircles =[{  
        latitude:39.925741,  
        longitude: 116.464372,  
        color:'#ff0000',  
        fillColor:'#CCFFFF80',  
        radius:600,  
        strokeWidth:3  
    }];  
    var testMarkers = [{  
        id:1,  
        latitude:39.925741,   
        longitude: 116.464372,  
        title:'测试1'  
    },{  
        id:2,  
        latitude:39.925165,   
        longitude: 116.45978,  
        title:'测试1'  
    }]  
    import amap from '../../../js/map/amap-wx.js';  
    export default {  
        data() {  
            return {  
                nowMapIndex:true,  
                phoneHeight:'',//屏幕高  
                phoneWidth:'',//屏幕宽  
                topViewHeight:'',  
                markers:[],  
                circles:[]  
            }  
        },  
        methods: {  
            getCircles:function(){  
                let that = this;  
                uni.chooseLocation({  
                    success: function (res) {  
                        console.log('位置名称:' + res.name);  
                        console.log('详细地址:' + res.address);  
                        console.log('纬度:' + res.latitude);  
                        console.log('经度:' + res.longitude);  
                        testMarkers[0].latitude=res.latitude;  
                        testMarkers[0].longitude=res.longitude;  
                        testCircles[0].latitude=res.latitude;  
                        testCircles[0].longitude=res.longitude;  
                        testCircles[0].radius=1;  
                        that.markers = testMarkers;  
                        that.circles = testCircles;  
                    }  
                });  
                console.log(that.circles)  
            },  
            getCircles2:function(){  
                console.log(this.circles)  
                testCircles[0].radius=600;  
                this.circles = testCircles;  
                console.log(this.circles)  
            }  
        },  
        onLoad() {  
            this.amapPlugin = new amap.AMapWX({  
                key: this.key  
            });  
        },  
    }  
</script>

该问题目前已经被锁定, 无法添加新回复