账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    高德地图polyline map.remove(polyline) 提示 remove is not defined
    31
    0

    我想判断polyline是否存在,存在 map.remove(polyline) 重新绘制,没找到方法,我绑定在我的

        $(document).on('click', '#workdata div', function(e) {
                    var $this = $(this);
        $this.addClass("drone-right-body-yi container-search-choose")
             var workid=$(e.target).attr("id"); 
               $.getJSON("/api/getdronelistpath/"+str+"?workid="+workid, function(data) {
                  for (var i = 0, len = data.length; i < len; i++) {
                          var path=data[i].path;
                          var lineArr = new Array();
                          lineArr.push(path);
                          var lineArr = path;
                    var polyline = new AMap.Polyline({
                          path: lineArr,          
                          strokeColor: "#DC143C", 
                          strokeOpacity: 0.8,      
                          strokeWeight: 3,        
                          strokeStyle: "solid",   //dashed
                          strokeDasharray: [10, 0]
                          });
                         map.setZoom(19);
                         map.setCenter(data[i].path[0]);
                         new AMap.Marker({
                         map: map,
                         position: data[i].path[0],
                         icon: new AMap.Icon({            
                         size: new AMap.Size(48, 48),  
                         image: "/static/img/start.png",
                         imageOffset: new AMap.Pixel(-2, 0)
                         })        
                         });
                         new AMap.Marker({
                         map: map,
                         position: data[i].path[path.length-1],
                         icon: new AMap.Icon({            
                         size: new AMap.Size(48, 48),  
                         image: "/static/img/end.png",
                         imageOffset: new AMap.Pixel(-2, 0)
                         })        
                         });
                        polyline.setMap(map);
                  } 
                })
                map.remove(polyline);//管用可以移除
                    if($this.siblings(".container-search-choose").length>0){
                        $this.siblings(".container-search-choose").addClass("drone-right-body-yi").removeClass("container-search-choose");
                        console.log(map)
                        //console.log(map)输出结果{_amap_id: 3, id: 3, CLASS_NAME: "AMap.Map", ho: true, C: div#container-map.amap-container, …}
                        map.remove(polyline);//无法移除 提示  Uncaught ReferenceError: remove is not defined
                    }
              })
    0
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    • 草生 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部