• 腾讯地图添加多个Marker


    //重置地图
            init(){
                var self = this;
                this.wSize = {
                    wHeight: window.innerHeight-80,
                    wWidth: window.innerWidth
                }
                //获取本市位置
                var citylocation = new qq.maps.CityService({
                    complete : function(result){
                        self.map.setCenter(result.detail.latLng);
                    }
                });
                citylocation.searchLocalCity();
                var center = new qq.maps.LatLng(39.914850, 116.403765);
                this.map = new qq.maps.Map(document.getElementById("container"),
                    {
                        center: center,
                        zoom: 13
                    }
                );
                // qq.maps.event.addDomListener(this.map, 'click', function(event) {
                //     self.addMarker(event.latLng);
                // });
            },
    //获取位置信息
            workersPos(){
                console.log(this.city3,this.value)
                var self = this;
                axios.get('http://work.121soft.cn:8089/lbs/lbs/public/index.php/api/servicer/getsonmap',{
                    params:{
                        rid:this.city3,
                        sid:this.value
                    }
                }).then((response)=>{
                    console.log(response);
                    this.workersInfor = response.data.data; 
                    this.setMarker();
                }).catch((response)=>{
                    console.log(response)
                })
            },
            //移除覆盖物
            deleteOverlays() {
                if (this.markersArray) {
                    for (i in this.markersArray) {
                        this.markersArray[i].setMap(null);
                    }
                    this.markersArray.length = 0;
                }
            },
            //设置覆盖物
            setMarker(){
                this.deleteOverlays();
                var self = this;
                this.latlngs2 = [];
                for (var prop in this.workersInfor) {
                    this.latlngs2.push('new qq.maps.LatLng('+this.workersInfor[prop].lat+','+this.workersInfor[prop].lng+')');
                }
                console.log(this.workersInfor)
                for(var i = 0;i < this.latlngs2.length; i++) {
                    (function(n){
                        var marker = new qq.maps.Marker({
                            position: eval(self.latlngs2[n]),
                            map: self.map
                        });
                        self.markersArray.push(marker);
                    })(i);
                }
            },
  • 相关阅读:
    QT -- 文本文件的读写(QFile、QTextStream)
    QT -- 单例模式
    QT -- 代码封装成库给C调用的问题
    QSS -- QSS入门1
    什么是 GPU 加速?
    QT -- 文件操作 QFile
    C++ -- break和continue的区别
    C++ -- Switch的基本用法
    C++ -- ?:运算符
    OpenCV -- cv::IMREAD_GRAYSCALE 与 cv::cvtColor
  • 原文地址:https://www.cnblogs.com/hzx-5/p/9808865.html
Copyright © 2020-2023  润新知