<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    busline

    ;(function(){
        var MapShare = App.MapShare, mapView= MapShare.mapView,
            detailView= MapShare.detailView,
            searchView= MapShare.searchView,
            // locationModel=MapShare.locationModel,
            routPathView = null, //來自后面實例化的。。。
            configLan=MapShare.configLan,
            topHeight=MapShare.topHeight;
        var AMap = window.AMap;    
        
        var loadingMov = {
            loadingBegin : App.loadingBegin,
            loadingFinish : App.loadingFinish
        };  
        var hasResulted = false;  
        var mapObj=mapView.getMapObj();    
        var SearchPathModel = PackTools.Model.extend({
            defaults: {
                busInfo: {start: {name:'', x:0, y:0}, end: {name:'', x:0, y:0}},
                busSearchOpt02:{
                    type: 0x02,
                    batch: 1,
                    number: 100
                },
                autoCompleterOpt:{
                    range: 10000,
                    sort: 0,
                    retvalue: 1
                }
            }
        })
        var searchPathModel=new SearchPathModel();
        var SearchPathView = PackTools.View.extend({
            el: $("#querypath"),    
            model: searchPathModel,
            initialize : function() {
                var $root = this.el;
                var $busList = $("#buslist");
                _.extend(this,{
                    $root : $root,
                    $startPlace : $root.find("#startPlace"),    //起點節點
                    $endPlace : $root.find("#endPlace"),        //終點節點
                    $searchBusLineBtn : $root.find(".pathform-seach-transit"),  //查詢公交的按鈕
                    $switchBtn : $root.find(".exchange_key"),         //切換起點和終點的按鈕
                    $searchSelfDriving : $root.find(".pathform-seach-selfdriving"),                
                    topbarback : $root.find('.position_box p'),
                    
                    $busList : $busList,
                    topbar:$busList.find('.position_box'),
                    busSearchBar : $busList.find('#busSearchBar'),
                    $listWrap : $busList.find("#listWrap"),
                    busBarPan: $busList.find("#busBarPan"),
                    $busStartTip : $busList.find("#busBarPan #startPlace"), //$busList.find(".bus-position-qi"),
                    $busEndTip : $busList.find('#busBarPan #endPlace'), //$busList.find(".bus-position-zhong"),
                    $busItemContainer : $busList.find(".bus-list"),
                    listTopbarback : $busList.find('.position_box p')
                });
                this.changeToCarBtn = this.topbar.find('.by_way ul li').eq(1);
                
                // this.busSearchBar = this.$listWrap.find('#busSearchBar');
                var view = this;
                this.changeToCarBtn.click(function(){
                    var busInfo = view.model.get('busInfo');
                    var startXY = new AMap.LngLat(busInfo.start.x, busInfo.start.y),
                        endXY = new AMap.LngLat(busInfo.end.x, busInfo.end.y);
                    searchPathView.el.hide();
                    searchPathView.$busList.hide();
                    if(!routPathView) routPathView = MapShare.routPathView;
                    routPathView.getRouteDetails(startXY, endXY, busInfo);
                });
                
                var spans = this.busSearchBar.find('span.text');
                for(var i=0,len=spans.length; i<len; i++){
                    spans.eq(i).tap((function(i){
                        return function(){
                            spans.removeClass('current');
                            if(i==0){
                                $(this).addClass('current');
                                searchPathView.model.set('busSearchOpt02',{
                                    type: 0x00,
                                    batch: 1,
                                    number: 100
                                })
                                searchPathView.searchBusLine();
                            }else if(i==1){
                                $(this).addClass('current');
                                searchPathView.model.set('busSearchOpt02',{
                                    type: 0x02,
                                    batch: 1,
                                    number: 100
                                })
                                searchPathView.searchBusLine();
                            }else if(i==2){
                                $(this).addClass('current');
                                searchPathView.model.set('busSearchOpt02',{
                                    type: 0x03,
                                    batch: 1,
                                    number: 100
                                })
                                searchPathView.searchBusLine();
                            }else if(i==3){
                                $(this).addClass('current');
                                searchPathView.model.set('busSearchOpt02',{
                                    type: 0x01,
                                    batch: 1,
                                    number: 100
                                })
                                searchPathView.searchBusLine();
                            }
                        }
                    })(i));
                }
                
                var busInfo = view.model.get('busInfo');
                this.topbarback.tap(function(){
                    hasResulted = false;
                    if(detailView.model.get('pageFrom')==detailView.name){
                         view.el.hide();
                         detailView.el.show();
                         //uPAResizePage();
                    }else{
                         searchPathView.backToSearchMain();
                    }
                    
                });
                this.$searchSelfDriving.on("click", function(e){
                    if(!view.$startPlace.text()){
                        mapView.showMapTip(configLan.Tip, configLan.putInStartPlace);
                        return;
                    }
                    if(!view.$endPlace.text()){
                        mapView.showMapTip(configLan.Tip, configLan.putInEndPlace);
                        return;
                    }
                    reviseBusInfo(busInfo.start);
                    var startXY = new AMap.LngLat(busInfo.start.x, busInfo.start.y),
                        endXY = new AMap.LngLat(busInfo.end.x, busInfo.end.y);
                    searchPathView.el.hide();
                    if(!routPathView) routPathView = MapShare.routPathView;
                    routPathView.getRouteDetails(startXY, endXY, busInfo);
                });
                //切換起點和終點
                this.$switchBtn.on("click", function(e){
                    if(!view.$startPlace.text()){
                        mapView.showMapTip(configLan.Tip, configLan.putInStartPlace);
                        return;
                    }
                    if(!view.$endPlace.text()){
                        mapView.showMapTip(configLan.Tip, configLan.putInEndPlace);
                        return;
                    }
                    var tempVal = view.$startPlace.text();
                    view.$startPlace.text(view.$endPlace.text());
                    view.$endPlace.text(tempVal);
                    reviseBusInfo(busInfo.start);
                    tempVal = busInfo.start; // MapShare.clone
                    busInfo.start = busInfo.end;
                    busInfo.end = tempVal;
                    return false;
                });
                
                //查詢公交路線
                this.$searchBusLineBtn.on("click", function() {
                    if(!view.$startPlace.text()){
                        mapView.showMapTip(configLan.Tip, configLan.putInStartPlace);
                        return;
                    }
                    if(!view.$endPlace.text()){
                        mapView.showMapTip(configLan.Tip, configLan.putInEndPlace);
                        return;
                    }
                    searchPathView.model.set('busSearchOpt02',{
                        type: 0x02,
                        batch: 1,
                        number: 100
                    })
                    searchPathView.searchBusLine();
                });//查詢公交路線
                
                this.listTopbarback.tap(function(){                
                    searchPathView.showSearchBus();
                });
                /* 暫時失效
                var isInList = true;
                this.$busItemContainer.on("click", ".bus-item", function(e) {
                    var $target = $(e.currentTarget), lineData = JSON.parse($target.attr("lineData"));
                    //console.dir(lineData);
                    isInList = false;
                    hasResulted = false;
                    searchPathView.showSearchMap(lineData);
                });
                */
            }, //initial
            setSearchInput : function(start, end){
                //start:起點名稱和位置 {name:'',x:number經度, y:number:緯度}, end終點的
                var busInfo = searchPathView.model.get('busInfo');
                if(start){
                    busInfo.start = {
                        name:start.name,
                        x:start.x,
                        y:start.y
                    };
                    this.$startPlace.text(start.name);
                }else{
                    this.$startPlace.text('');
                }
                if(end){
                    busInfo.end = {
                        name:end.name,
                        x:end.x,
                        y:end.y
                    }
                    this.$endPlace.text(end.name);
                }else{
                    this.$endPlace.text('');
                }
                this.el.show();
                //uPAResizePage();
            },
            backToSearchMain : function(){
                // mapView.getMapObj().clearMap();
                mapView.showCenterMap();
                searchPathView.el.hide();
                searchPathView.$busList.hide();
                mapView.el.show();    
                //uPAResizePage();
            },
            searchBusLine : function(){
                loadingMov.loadingBegin();
                var busInfo = searchPathView.model.get('busInfo');
                reviseBusInfo(busInfo.start);
                
                var startXY = new AMap.LngLat(busInfo.start.x, busInfo.start.y),
                    endXY = new AMap.LngLat(busInfo.end.x, busInfo.end.y),
                    busSearcher = new AMap.BusSearch(searchPathView.model.get('busSearchOpt02')),
                    city = mapView.model.city || '';
                
                searchPathView.$busStartTip.html(busInfo.start.name);
                searchPathView.$busEndTip.html(busInfo.end.name);
                searchPathView.$busItemContainer.empty();
                busSearcher.byTwoPoi([startXY, endXY], city, function(data) {
                    var list = data.list, line = [], currPaths, items = [], currItem, title, itemPath, content;
                    if(list && list.length) {
                        for(var i = 0, len = list.length; i < len; i ++) {
                            currItem = $('<div class="bus-item"/>');
                            title = $('<div class="bus-item-title"/>');
                            content = $('<div class="bus-item-content"/>');
                            itemPath = $('<div class="bus-item-path"/>');
                            line = list[i];
                            currPaths = line.segmentList;
                            title.html('<p class="bus-item-no">' +
                            leftPad("0", 2, ""+(i+1))
                            +'</p>');
                            for(var j = 0, jLen = currPaths.length; j < jLen; j ++) {
                                itemPath.append('<p class="bus-item-path-text">' +
                                    currPaths[j].busName
                                +'</p>\
                                <p class="bus-item-path-remark">' +
                                    currPaths[j].startName+' '+currPaths[j].passDepotName+' '+currPaths[j].endName
                                + '</p>');
                            }
                            title.append(itemPath).append('<p class="bus-item-icon">&nbsp;</p>');
                            currItem.append(title).append(content);
                            items.push(currItem[0]);
                            currItem.attr("lineData", JSON.stringify(line)); //attr
                        }
                        searchPathView.$busItemContainer.append(items);
                    }
                    
                    // searchPathView.$busList.css({
                        // position:'relative',
                        // top: 'auto'
                    // });
                    // $root.hide();
                    // $busList.show();
                    // uPAResizePage();
                    searchPathView.showSearchList();
                    loadingMov.loadingFinish();
                }); //byTwoPoi    
            },
            showSearchMap : function(lineData){
                searchPathView.$busList.css({
                    position:'absolute',
                    top: topHeight+'px',
                    'z-index': 501
                });    
                
                if(!hasResulted){
                   mapObj.clearMap();
                   searchPathView.drawBusLine(lineData);
                   hasResulted = true;
                }
                mapView.showCenterMap(true);
                // searchPathView.el.hide();
                searchPathView.busSearchBar.hide();
                searchPathView.$listWrap.hide();
                mapView.el.show();    
                searchPathView.busBarPan.css({
                    position:'absolute',
                    'z-index': 501,
                    'margin-top': mapView.el.height()-searchPathView.topbar.height()-searchPathView.busBarPan.height()+'px'
                });
                //162 底部欄高度不知為何得不到
                //uPAResizePage();
            },
            showSearchList : function(){
                searchPathView.$busList.css({
                    position:'relative',
                    top: 'auto'
                });    
                searchPathView.$root.hide();
                searchPathView.busSearchBar.show();
                searchPathView.$listWrap.show();
                mapView.el.hide();  
                searchPathView.$busList.show();  
                searchPathView.busBarPan.css({
                    position:'relative',
                    'margin-top':'0px'
                });
                //uPAResizePage();
                // $busList.hide();
                // mapView.showCenterMap();
                // mapView.el.show();    
                // searchPathView.$root.hide();
                // uPAResizePage();
            },
            showSearchBus : function(){
                searchPathView.$busList.hide();
                // mapView.showCenterMap();
                mapView.el.hide();    
                searchPathView.$root.show();
                //uPAResizePage();
            },
            /**
             * 畫地圖上的線的方法
             * @param lineData 數據
             */
            drawBusLine:function(lineData){
                var lineList = lineData.segmentList, aLine, tempBusXY,
                    busXY = [],     //公交經過的線路的經緯度數組
                    tempBusXY_xy,
                    view=this;
                if(lineList && lineList.length) {
                    for(var i = 0, iLen = lineList.length; i < iLen; i ++) {
                        aLine = lineList[i];
                        tempBusXY = aLine.coordinateList.split(";");
                        for(var j = 0, jLen = tempBusXY.length; j < jLen; j ++) {
                            tempBusXY_xy = tempBusXY[j].split(',')
                            busXY.push(new AMap.LngLat(tempBusXY_xy[0], tempBusXY_xy[1]));
                            if(j === 0 || jLen === j+1) {
                                view.drawBusStation(new AMap.LngLat(tempBusXY_xy[0], tempBusXY_xy[1]), i, j,
                                    j === 0 &&("名稱:" + aLine.startName + "<br/>類型: 公交站<br/>公交路線名:" + aLine.busName)||("名稱:" + aLine.endName + "<br/>類型: 公交站<br/>公交路線名:" + aLine.busName));
                            }
                        }
                    }
                    var line = new AMap.Polyline({
                        map: mapObj,
                        path : busXY, //線經緯度數組
                        strokeColor : "#005cb5", //線顏色
                        strokeOpacity : 0.8, //線透明度
                        strokeWeight : 6 //線寬
                    });
                    //mapObj.setFitView();
                }
            },
            /**
             * 標示公交站
             * @param data 數據
             */
            drawBusStation : function(change, i, j,  name){
                var marker = new AMap.Marker({
                    map: mapObj,
                    draggable: 0,
                    icon : "http://webapi.amap.com/images/bx11.png", //復雜圖標
                    visible : true, //可見
                    position : change
                });
                var infoWindow = new AMap.InfoWindow({
                    size: new AMap.Size(400, 150),
                    offset: new AMap.Pixel(0, -30), //new AMap.Pixel(0, -30),
                    content: name
                });
                if(i === j && 0 === i) {
                    infoWindow.open(mapObj, marker.getPosition());
                }
                mapObj.bind(marker, 'click', function() {
                    if(infoWindow.getIsOpen()) {
                        infoWindow.close();
                    } else {
                        infoWindow.open(mapObj, marker.getPosition());
                    }
                });
            }
        });
        var searchPathView = new SearchPathView();
        function leftPad(theChar, num, str) {
            if(str.length >= num){
                 return str;
            }else {
                for(var i = str.length; i < num; i ++) {
                    str = theChar + str;
                }
                return str;
            }
        }
        function reviseBusInfo(place){
            if(!place.x || !place.y){
                var aroundLocal=mapView.model.get('aroundLocal');
                place.name = aroundLocal.name;
                place.x=aroundLocal.pos.lng;
                place.y=aroundLocal.pos.lat;
            }
        }
        App.MapShare.searchPathView = searchPathView;
        App.MapShare.searchPathModel = searchPathModel;
    })();

    posted on 2014-04-22 09:48 koradji 閱讀(206) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    統計

    常用鏈接

    留言簿(2)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    收藏夾

    db2

    dos

    Groovy

    Hibernate

    java

    WAS

    web application

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 男女作爱在线播放免费网站| a级毛片在线免费| 午夜福利不卡片在线播放免费| 久久精品亚洲中文字幕无码网站| 精品国产污污免费网站入口 | 亚洲一区免费在线观看| 亚洲国产精品成人久久| 国产免费阿v精品视频网址| 亚洲日韩激情无码一区| 中国一级毛片视频免费看| 久久精品国产亚洲网站| a在线免费观看视频| 亚洲va中文字幕无码久久| 麻豆成人久久精品二区三区免费 | 在线视频免费国产成人| MM1313亚洲精品无码久久| xvideos亚洲永久网址| 国产黄在线播放免费观看| 国产亚洲成AV人片在线观黄桃| 日本免费人成网ww555在线| 亚洲美女视频免费| 无码一区二区三区AV免费| 亚洲gay片在线gv网站| 免费人成在线观看网站视频| 一区二区三区在线观看免费| 亚洲午夜福利717| 91精品视频在线免费观看| 亚洲一区二区三区在线| 免费萌白酱国产一区二区| 香蕉免费看一区二区三区| 久久亚洲精品中文字幕| 日韩免费无砖专区2020狼| 国产免费久久久久久无码| 久久久久亚洲精品影视| 67194成是人免费无码| 免费国产va在线观看| 亚洲国产成人久久精品影视| 免费可以在线看A∨网站| 九九九国产精品成人免费视频| 亚洲视频在线免费看| 国产精品极品美女免费观看 |