在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  HTML/ 為什么切換城市之后還會(huì)有上次的數(shù)據(jù)殘留下來(lái),為什么???急急急!?。∧奈淮罄锌梢?/span>

為什么切換城市之后還會(huì)有上次的數(shù)據(jù)殘留下來(lái),為什么???急急急?。?!哪位大佬可以幫忙看看

現(xiàn)在默認(rèn)顯示的是成都市,每個(gè)點(diǎn)代表一輛車在動(dòng);如圖圖片描述

但是當(dāng)我切換城市的時(shí)候,會(huì)有之前城市的車子的殘影留在地圖上
如圖圖片描述

我紅色箭頭標(biāo)記的代表的是深圳市的車輛,其他的那些點(diǎn)點(diǎn)都是上個(gè)城市的車輛殘影,這個(gè)要怎么解決?在切換城市的時(shí)候沒(méi)有這個(gè)殘留的影子;### 問(wèn)題描述
這是切換城市的代碼
$(".box li").on('click', function () {

                var val = $(this).text();

                var cs = $(this).find('a').attr('class');

                city=cs;

                bigdata.zkAjax();
                mapEcharts.clear();
                bigdata.mapAjax();
                
                $(".citys").text(val);

                // $(".box").hide();
            })

用的是echarts控件,用了clear()方法,還是會(huì)出現(xiàn)這種斑點(diǎn),就是上個(gè)城市的數(shù)據(jù)沒(méi)有被清除掉,然后遺留下來(lái)的,急急急?。?!

代碼如下,

            var data = data.result.map(function (v) {
                return v.points;
            })
            var hStep = 300 / (data.length - 1);

            var busLines = [].concat.apply([], data.map(function (busLine, idx) {
                var prevPt;
                var points = [];
                for (var i = 0; i < busLine.length; i += 2) {
                    // busLine[i]  所展示的是每一輛車的經(jīng)緯度 

                    var pt = [busLine[i], busLine[i + 1]];

                    // pt  是一個(gè)經(jīng)緯度的數(shù)組   就是把這輛車每移動(dòng)的一個(gè)經(jīng)緯度添加為一個(gè)數(shù)組  

                    if (i > 0 && i < busLine.length) {
                        pt = [
                            prevPt[0] + pt[0],
                            prevPt[1] + pt[1]
                        ];
                    }
                    prevPt = pt;

                    points.push([pt[0] / 1e6, pt[1] / 1e6]);
                }
                return {
                    coords: points,
                    lineStyle: {
                        normal: {
                            color: echarts.color.modifyHSL('#5A94DF', Math.round(hStep * idx))
                        }
                    }
                };
            }));
            var jwds=[];
            var ds=busLines.forEach(function(v) {
                var obj={
                    jd:v.coords[0][0],
                    wd:v.coords[0][1],
                }
                jwds.push(obj);
                
            })
            var startPoint = {
                x: jwds[0].jd,
                y: jwds[0].wd
            };

            // console.log(data);
            mapEcharts.setOption(option = {
                bmap: {
                    center: [startPoint.x,startPoint.y],
                    zoom: 12,
                    // centerAndZoom:("深圳",17),
                    roam: true,
                    mapStyle: {
                        'styleJson': [{
                                'featureType': 'water',
                                'elementType': 'all',
                                'stylers': {
                                    'color': '#031628'
                                }
                            },
                            {
                                'featureType': 'land',
                                'elementType': 'geometry',
                                'stylers': {
                                    'color': '#000102'
                                }
                            },
                            {
                                'featureType': 'highway',
                                'elementType': 'all',
                                'stylers': {
                                    'visibility': 'off'
                                }
                            },
                            {
                                'featureType': 'arterial',
                                'elementType': 'geometry.fill',
                                'stylers': {
                                    'color': '#000000'
                                }
                            },
                            {
                                'featureType': 'arterial',
                                'elementType': 'geometry.stroke',
                                'stylers': {
                                    'color': '#0b3d51'
                                }
                            },
                            {
                                'featureType': 'local',
                                'elementType': 'geometry',
                                'stylers': {
                                    'color': '#000000'
                                }
                            },
                            {
                                'featureType': 'railway',
                                'elementType': 'geometry.fill',
                                'stylers': {
                                    'color': '#000000'
                                }
                            },
                            {
                                'featureType': 'railway',
                                'elementType': 'geometry.stroke',
                                'stylers': {
                                    'color': '#08304b'
                                }
                            },
                            {
                                'featureType': 'subway',
                                'elementType': 'geometry',
                                'stylers': {
                                    'lightness': -70
                                }
                            },
                            {
                                'featureType': 'building',
                                'elementType': 'geometry.fill',
                                'stylers': {
                                    'color': '#000000'
                                }
                            },
                            {
                                'featureType': 'all',
                                'elementType': 'labels.text.fill',
                                'stylers': {
                                    'color': '#857f7f'
                                }
                            },
                            {
                                'featureType': 'all',
                                'elementType': 'labels.text.stroke',
                                'stylers': {
                                    'color': '#000000'
                                }
                            },
                            {
                                'featureType': 'building',
                                'elementType': 'geometry',
                                'stylers': {
                                    'color': '#022338'
                                }
                            },
                            {
                                'featureType': 'green',
                                'elementType': 'geometry',
                                'stylers': {
                                    'color': '#062032'
                                }
                            },
                            {
                                'featureType': 'boundary',
                                'elementType': 'all',
                                'stylers': {
                                    'color': '#465b6c'
                                }
                            },
                            {
                                'featureType': 'manmade',
                                'elementType': 'all',
                                'stylers': {
                                    'color': '#022338'
                                }
                            },
                            {
                                'featureType': 'label',
                                'elementType': 'all',
                                'stylers': {
                                    'visibility': 'off'
                                }
                            }
                        ]
                    }
                },
                series: [{
                    type: 'lines',
                    coordinateSystem: 'bmap',
                    polyline: true,
                    data: busLines,
                    silent: true,
                    lineStyle: {
                        normal: {
                            // color: '#c23531',
                            // color: 'rgb(200, 35, 45)',
                            opacity: 0.2,
                            width: 1
                        }
                    },
                    progressiveThreshold: 500,
                    progressive: 200
                }, {
                    type: 'lines',
                    coordinateSystem: 'bmap',
                    polyline: true,
                    data: busLines,
                    lineStyle: {
                        normal: {
                            width: 0
                        }
                    },
                    effect: {
                        constantSpeed: 20,
                        show: true,
                        trailLength: 0.1,
                        symbolSize: 1.5
                    },
                    zlevel: 1
                }]
            },true);
            

問(wèn)題描述

問(wèn)題出現(xiàn)的環(huán)境背景及自己嘗試過(guò)哪些方法

相關(guān)代碼

// 請(qǐng)把代碼文本粘貼到下方(請(qǐng)勿用圖片代替代碼)

你期待的結(jié)果是什么?實(shí)際看到的錯(cuò)誤信息又是什么?

回答
編輯回答
墻頭草

如果實(shí)在找不到好的方法可以先銷毀再初始化。

$(".box li").on('click', function () {
    var val = $(this).text();
    var cs = $(this).find('a').attr('class');
    city=cs;
    mapEcharts.dispose();
    mapEcharts = echarts.init(dom);
    bigdata.zkAjax();
    bigdata.mapAjax();
    $(".citys").text(val);
    // $(".box").hide();
})

另外切換的時(shí)候會(huì)出現(xiàn)下面這種情況

clipboard.png
偶發(fā)的bug,切換到成都的時(shí)候出現(xiàn)概率較大

2017年2月10日 09:03