From 89da62649161571834d3f8df7ce36f9967e6ba04 Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期二, 07 九月 2021 14:04:31 +0800
Subject: [PATCH] change cesium version

---
 widgets/queryBaiduPOI/widget.js | 1068 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 546 insertions(+), 522 deletions(-)

diff --git a/widgets/queryBaiduPOI/widget.js b/widgets/queryBaiduPOI/widget.js
index d8bc63d..5a371d5 100644
--- a/widgets/queryBaiduPOI/widget.js
+++ b/widgets/queryBaiduPOI/widget.js
@@ -1,564 +1,588 @@
-'use script' //寮�鍙戠幆澧冨缓璁紑鍚弗鏍兼ā寮�
-  ; (function (window, mars3d) {
-    //鍒涘缓widget绫伙紝闇�瑕佺户鎵緽aseWidget
-    class MyWidget extends mars3d.widget.BaseWidget {
-      //澶栭儴璧勬簮閰嶇疆
-      get resources() {
-        return ['view.css']
-      }
+"use script"; //寮�鍙戠幆澧冨缓璁紑鍚弗鏍兼ā寮�
+(function (window, mars3d) {
+  //鍒涘缓widget绫伙紝闇�瑕佺户鎵緽aseWidget
+  class MyWidget extends mars3d.widget.BaseWidget {
+    //澶栭儴璧勬簮閰嶇疆
+    get resources() {
+      return ["view.css"];
+    }
 
-      //寮圭獥閰嶇疆
-      get view() {
-        return {
-          type: 'append',
-          url: 'view.html',
-          parent: 'body',
-        }
-      }
+    //寮圭獥閰嶇疆
+    get view() {
+      return {
+        type: "append",
+        url: "view.html",
+        parent: "body",
+      };
+    }
 
-      //鍒濆鍖朳浠呮墽琛�1娆
-      create() {
-        this.storageName = 'mars3d_queryBaiduPOI'
-        this.pageSize = 6
-        this.arrdata = []
-        this.counts = 0
-        this.allpage = 0
-        this.thispage = 0
+    //鍒濆鍖朳浠呮墽琛�1娆
+    create() {
+      this.storageName = "mars3d_queryBaiduPOI";
+      this.pageSize = 6;
+      this.allpage = 0;
+      this.thispage = 0;
+      this.txt_querypoi_show = false;
 
-        //鍒涘缓鐭㈤噺鏁版嵁鍥惧眰
-        this.graphicLayer = new mars3d.layer.GraphicLayer({
-          name: this.config.name,
-          pid: 99, //鍥惧眰绠$悊 涓娇鐢紝鐖惰妭鐐筰d
-        })
-        //榧犳爣鍗曞嚮鍚庣殑淇℃伅闈㈡澘寮圭獥
-        this.graphicLayer.bindPopup(
-          function (event) {
-            let item = event.graphic?.attr
-            if (!item) {
-              return
-            }
-
-            var name
-            if (item.detail_info && item.detail_info.detail_url) {
-              name = '<a href="' + item.detail_info.detail_url + '"  target="_black" style="color: #ffffff; ">' + item.name + '</a>'
-            } else {
-              name = item.name
-            }
-
-            var inHtml = '<div class="mars-popup-titile">' + name + '</div><div class="mars-popup-content" >'
-
-            var phone = $.trim(item.tel)
-            if (phone != '') {
-              inHtml += '<div><label>鐢佃瘽</label>' + phone + '</div>'
-            }
-
-            var dz = $.trim(item.address)
-            if (dz != '') {
-              inHtml += '<div><label>鍦板潃</label>' + dz + '</div>'
-            }
-
-            if (item.detail_info) {
-              var fl = $.trim(item.detail_info.tag)
-              if (fl != '') {
-                inHtml += '<div><label>绫诲埆</label>' + fl + '</div>'
-              }
-            }
-            inHtml += '</div>'
-
-            return inHtml
-          },
-          {
-            anchor: [0, -10],
-          }
-        )
-
-        //鏌ヨ鎺у埗鍣�
-        this.baiduPOI = new mars3d.query.BaiduPOI()
-      }
-      //姣忎釜绐楀彛鍒涘缓瀹屾垚鍚庤皟鐢�
-      winCreateOK(opt, result) {
-        if (opt.type != 'append') {
-          return
-        }
-        var that = this
-        var img = $('#map-querybar img')
-        img.each((index, item) => {
-          $(item).attr('src', this.path + $(item).attr('src'))
-        })
-
-        if (this.config.position) {
-          $('#map-querybar').css(this.config.position)
-        }
-        if (this.config.style) {
-          $('#map-querybar').css(this.config.style)
+      //鍒涘缓鐭㈤噺鏁版嵁鍥惧眰
+      this.graphicLayer = new mars3d.layer.GraphicLayer({
+        name: this.config.name,
+        pid: 99, //鍥惧眰绠$悊 涓娇鐢紝鐖惰妭鐐筰d
+      });
+      //榧犳爣鍗曞嚮鍚庣殑淇℃伅闈㈡澘寮圭獥
+      this.graphicLayer.bindPopup(function (event) {
+        let item = event.graphic?.attr;
+        if (!item) {
+          return;
         }
 
-        // 鎼滅储妗�
-        $('#txt_querypoi').click(function () {
-          // 鏂囨湰妗嗗唴瀹逛负绌�
-          if ($.trim($(this).val()).length == 0) {
-            that.hideAllQueryBarView()
-            that.showHistoryList() // 鏄剧ず鍘嗗彶璁板綍
-          }
-        })
-
-        var timetik = 0
-
-        // 鎼滅储妗嗙粦瀹氭枃鏈鍊煎彂鐢熷彉鍖�,闅愯棌榛樿鎼滅储淇℃伅鏍�,鏄剧ず鍖归厤缁撴灉鍒楄〃
-        $('#txt_querypoi').bind('input propertychange', () => {
-          clearTimeout(timetik)
-          timetik = setTimeout(() => {
-            this.hideAllQueryBarView()
-            this.clearLayers()
-
-            var queryVal = $.trim($('#txt_querypoi').val())
-            if (queryVal.length == 0) {
-              // 鏂囨湰妗嗗唴瀹逛负绌�,鏄剧ず鍘嗗彶璁板綍
-              this.showHistoryList()
-            } else {
-              this.autoTipList(queryVal, true)
-            }
-          }, 500)
-        })
-
-        // 鐐瑰嚮鎼滅储鏌ヨ鎸夐挳
-        $('#btn_querypoi').click(() => {
-
-          if ($('#txt_querypoi').css('display') == 'none') {
-            $('#txt_querypoi').show();
-          } else {
-            clearTimeout(timetik)
-            this.hideAllQueryBarView()
-
-            var queryVal = $.trim($('#txt_querypoi').val())
-            this.strartQueryPOI(queryVal, true)
-          }
-        })
-        //缁戝畾鍥炶溅閿�
-        $('#txt_querypoi').bind('keydown', (event) => {
-          if (event.keyCode == '13') {
-            $('#btn_querypoi').click()
-          }
-        })
-
-        // 杩斿洖鏌ヨ缁撴灉闈㈡澘鐣岄潰
-        $('#querybar_detail_back').click(() => {
-          this.hideAllQueryBarView()
-          $('#querybar_resultlist_view').show()
-        })
-      }
-      //鎵撳紑婵�娲�
-      activate() {
-        this.map.addLayer(this.graphicLayer)
-
-        //鍗曞嚮鍦板浘浜嬩欢
-        this.map.on(mars3d.EventType.clickMap, this.onMapClick, this)
-      }
-      //鍏抽棴閲婃斁
-      disable() {
-        this.map.removeLayer(this.graphicLayer)
-
-        //閲婃斁鍗曞嚮鍦板浘浜嬩欢
-        this.map.off(mars3d.EventType.clickMap, this.onMapClick, this)
-
-        this.hideAllQueryBarView()
-        this.clearLayers()
-      }
-      onMapClick(event) {
-        // 鐐瑰嚮鍦板浘鍖哄煙,闅愯棌鎵�鏈夊脊鍑烘
-        if ($.trim($('#txt_querypoi').val()).length == 0) {
-          this.hideAllQueryBarView()
-          //$('#txt_querypoi').blur()
-          $('#txt_querypoi').hide()
-
-        }
-      }
-      hideAllQueryBarView() {
-        $('#querybar_histroy_view').hide()
-        $('#querybar_autotip_view').hide()
-        $('#querybar_detail_view').hide()
-        $('#querybar_resultlist_view').hide()
-      }
-
-      // 鐐瑰嚮闈㈡澘鏉$洰,鑷姩濉厖鎼滅储妗�,骞跺睍绀烘悳绱㈢粨鏋滈潰鏉�
-      autoSearch(name) {
-        $('#txt_querypoi').val(name)
-        $('#btn_querypoi').trigger('click')
-      }
-
-      //===================涓庡悗鍙颁氦浜�========================
-
-      //鏄剧ず鏅鸿兘鎻愮ず鎼滅储缁撴灉
-      autoTipList(text, queryEx) {
-        //杈撳叆缁忕含搴︽暟瀛楁椂
-        if (this.isLonLat(text)) {
-          return
-        }
-
-        //鏌ヨ澶栭儴widget
-        if (this.hasExWidget() && queryEx) {
-          this.autoExTipList(text)
-          return
-        }
-        //鏌ヨ澶栭儴widget
-
-        this.baiduPOI.autoTip({
-          text: text,
-          location: this.map.getCenter(),
-          success: (result) => {
-            var inhtml = ''
-            var pois = result.list
-            for (var index = 0; index < pois.length; index++) {
-              var name = pois[index].name
-              // var num = pois[index].num;
-              // if (num > 0) continue;
-
-              inhtml += "<li><i class='fa fa-search'></i><a href=\"javascript:queryBaiduPOIWidget.autoSearch('" + name + '\');">' + name + '</a></li>'
-            }
-
-            if (inhtml.length > 0) {
-              $('#querybar_ul_autotip').html(inhtml)
-              $('#querybar_autotip_view').show()
-            }
-          },
-        })
-      }
-
-      // 鏍规嵁杈撳叆妗嗗唴瀹癸紝鏌ヨ鏄剧ず鍒楄〃
-      strartQueryPOI(text, queryEx) {
-        if (text.length == 0) {
-          toastr.warning('璇疯緭鍏ユ悳绱㈠叧閿瓧锛�')
-          return
-        }
-
-        // TODO:鏍规嵁鏂囨湰妗嗚緭鍏ュ唴瀹�,浠庢暟鎹簱妯$硦鏌ヨ鍒版墍鏈夊尮閰嶇粨鏋滐紙鍒嗛〉鏄剧ず锛�
-        this.addHistory(text)
-
-        this.hideAllQueryBarView()
-
-        //杈撳叆缁忕含搴︽暟瀛楁椂
-        if (this.isLonLat(text)) {
-          this.centerAtLonLat(text)
-          return
-        }
-
-        //鏌ヨ澶栭儴widget
-        if (this.hasExWidget() && queryEx) {
-          var qylist = this.queryExPOI(text)
-          return
-        }
-        //鏌ヨ澶栭儴widget
-
-        this.thispage = 1
-        this.queryText = text
-        this.query_location = this.map.getCenter()
-        this.query_radius = this.map.camera.positionCartographic.height //鍗曚綅锛氱背
-
-        this.queryPOI()
-      }
-      queryPOI() {
-        //鏌ヨ鑾峰彇鏁版嵁
-        this.baiduPOI.queryText({
-          text: this.queryText,
-          count: this.pageSize,
-          page: this.thispage - 1,
-          location: this.query_location,
-          radius: this.query_radius,
-          success: (result) => {
-            if (!this.isActivate) {
-              return
-            }
-            this.showPOIPage(result.list, result.allcount)
-          },
-        })
-      }
-
-      //===================鏄剧ず鏌ヨ缁撴灉澶勭悊========================
-      showPOIPage(data, counts) {
-        this.arrdata = data
-        this.counts = counts
-        if (this.counts < data.length) {
-          this.counts = data.length
-        }
-        this.allpage = Math.ceil(this.counts / this.pageSize)
-
-        var inhtml = ''
-        if (this.counts == 0) {
-          inhtml += '<div class="querybar-page"><div class="querybar-fl">娌℃湁鎵惧埌"<strong>' + this.queryText + '</strong>"鐩稿叧缁撴灉</div></div>'
+        var name;
+        if (item.detail_info && item.detail_info.detail_url) {
+          name = '<a href="' + item.detail_info.detail_url + '"  target="_black" style="color: #ffffff; ">' + item.name + "</a>";
         } else {
-          this.objResultData = this.objResultData || {}
-          for (var index = 0; index < this.arrdata.length; index++) {
-            var item = this.arrdata[index]
-            var startIdx = (this.thispage - 1) * this.pageSize
-            item.index = startIdx + (index + 1)
+          name = item.name;
+        }
 
-            var _id = index
-            var _mc
-            if (item.detail_info && item.detail_info.detail_url) {
-              _mc = '<a href="' + item.detail_info.detail_url + '"  target="_black" style="color: #ffffff; ">' + item.name + '</a>'
-            } else {
-              _mc = item.name
-            }
+        var inHtml = '<div class="mars-popup-titile">' + name + '</div><div class="mars-popup-content" >';
 
-            inhtml +=
-              '<div class="querybar-site" onclick="queryBaiduPOIWidget.showDetail(\'' +
-              _id +
-              '\')"> <div class="querybar-sitejj"> <h3>' +
-              item.index +
-              '銆�' +
-              _mc +
-              '</h3> <p>' +
-              (item.address || '') +
-              '</p> </div> </div>'
+        var phone = $.trim(item.tel);
+        if (phone != "") {
+          inHtml += "<div><label>鐢佃瘽</label>" + phone + "</div>";
+        }
 
-            this.objResultData[_id] = item
+        var dz = $.trim(item.address);
+        if (dz != "") {
+          inHtml += "<div><label>鍦板潃</label>" + dz + "</div>";
+        }
+
+        if (item.type) {
+          var fl = $.trim(item.type);
+          if (fl != "") {
+            inHtml += "<div><label>绫诲埆</label>" + fl + "</div>";
           }
+        }
+        inHtml += "</div>";
 
-          //鍒嗛〉淇℃伅
-          var _fyhtml
-          if (this.allpage > 1) {
-            _fyhtml =
-              '<div class="querybar-ye querybar-fr">' +
-              this.thispage +
-              '/' +
-              this.allpage +
-              '椤�  <a href="javascript:queryBaiduPOIWidget.showFirstPage()">棣栭〉</a> <a href="javascript:queryBaiduPOIWidget.showPretPage()">&lt;</a>  <a href="javascript:queryBaiduPOIWidget.showNextPage()">&gt;</a> </div>'
+        return inHtml;
+      });
+
+      //鏌ヨ鎺у埗鍣�
+      this._queryPoi = new mars3d.query.BaiduPOI({
+        city: '涓婃捣甯�'
+      });
+    }
+    //姣忎釜绐楀彛鍒涘缓瀹屾垚鍚庤皟鐢�
+    winCreateOK(opt, result) {
+      if (opt.type != "append") {
+        return;
+      }
+      var that = this;
+      var img = $("#map-querybar img");
+      img.each((index, item) => {
+        $(item).attr("src", this.path + $(item).attr("src"));
+      });
+
+      if (this.config.position) {
+        $("#map-querybar").css(this.config.position);
+      }
+      if (this.config.style) {
+        $("#map-querybar").css(this.config.style);
+      }
+
+      // 鎼滅储妗�
+      $("#txt_querypoi").hide();
+
+      $("#txt_querypoi").click(function () {
+        // 鏂囨湰妗嗗唴瀹逛负绌�
+        if ($.trim($(this).val()).length == 0) {
+          that.hideAllQueryBarView();
+          that.showHistoryList(); // 鏄剧ず鍘嗗彶璁板綍
+        }
+      });
+
+      var timetik = 0;
+
+      // 鎼滅储妗嗙粦瀹氭枃鏈鍊煎彂鐢熷彉鍖�,闅愯棌榛樿鎼滅储淇℃伅鏍�,鏄剧ず鍖归厤缁撴灉鍒楄〃
+      $("#txt_querypoi").bind("input propertychange", () => {
+        clearTimeout(timetik);
+        timetik = setTimeout(() => {
+          this.hideAllQueryBarView();
+          this.clearLayers();
+
+          var queryVal = $.trim($("#txt_querypoi").val());
+          if (queryVal.length == 0) {
+            // 鏂囨湰妗嗗唴瀹逛负绌�,鏄剧ず鍘嗗彶璁板綍
+            this.showHistoryList();
           } else {
-            _fyhtml = ''
+            this.autoTipList(queryVal, true);
+          }
+        }, 500);
+      });
+
+      // 鐐瑰嚮鎼滅储鏌ヨ鎸夐挳
+      $("#btn_querypoi").click(() => {
+
+        if (!this.txt_querypoi_show) {
+          $("#txt_querypoi").show();
+          this.txt_querypoi_show = true;
+        } else {
+          clearTimeout(timetik);
+          this.hideAllQueryBarView();
+          var queryVal = $.trim($("#txt_querypoi").val());
+          this.strartQueryPOI(queryVal, true);
+        }
+      });
+      //缁戝畾鍥炶溅閿�
+      $("#txt_querypoi").bind("keydown", (event) => {
+        if (event.keyCode == "13") {
+          $("#btn_querypoi").click();
+        }
+      });
+
+      // 杩斿洖鏌ヨ缁撴灉闈㈡澘鐣岄潰
+      $("#querybar_detail_back").click(() => {
+        this.hideAllQueryBarView();
+        $("#querybar_resultlist_view").show();
+      });
+    }
+    //鎵撳紑婵�娲�
+    activate() {
+      this.map.addLayer(this.graphicLayer);
+
+      $(".mars3d-locationbar").append('<div id="queryAddress" class="mars3d-locationbar-content" style="margin-right: 50px;"></div>');
+
+      //鍗曞嚮鍦板浘浜嬩欢
+      this.map.on(mars3d.EventType.clickMap, this.onMapClick, this);
+      this.map.on(mars3d.EventType.cameraChanged, this.onMapCameraChanged, this);
+    }
+    //鍏抽棴閲婃斁
+    disable() {
+      this.map.removeLayer(this.graphicLayer);
+
+      //閲婃斁鍗曞嚮鍦板浘浜嬩欢
+      this.map.off(mars3d.EventType.clickMap, this.onMapClick, this);
+      this.map.off(mars3d.EventType.cameraChanged, this.onMapCameraChanged, this);
+
+      $("#queryAddress").remove();
+
+      this.hideAllQueryBarView();
+      this.clearLayers();
+    }
+    onMapClick(event) {
+      // 鐐瑰嚮鍦板浘鍖哄煙,闅愯棌鎵�鏈夊脊鍑烘
+      if ($.trim($("#txt_querypoi").val()).length == 0) {
+        this.hideAllQueryBarView();
+        //$("#txt_querypoi").blur();
+        $("#txt_querypoi").hide();
+        this.txt_querypoi_show = false;
+      }
+    }
+    onMapCameraChanged(event) {
+      let radius = this.map.camera.positionCartographic.height; //鍗曚綅锛氱背
+      if (radius > 100000) {
+        this.address = null;
+        $("#queryAddress").html("");
+        return;
+      }
+
+      this._queryPoi.getAddress({
+        location: this.map.getCenter(),
+        success: (result) => {
+          // console.log('鍦板潃', result)
+          this.address = result;
+
+          $("#queryAddress").html("鍦板潃锛�" + result.address);
+        },
+      });
+    }
+    hideAllQueryBarView() {
+      $("#querybar_histroy_view").hide();
+      $("#querybar_autotip_view").hide();
+      $("#querybar_detail_view").hide();
+      $("#querybar_resultlist_view").hide();
+    }
+
+    // 鐐瑰嚮闈㈡澘鏉$洰,鑷姩濉厖鎼滅储妗�,骞跺睍绀烘悳绱㈢粨鏋滈潰鏉�
+    autoSearch(name) {
+      $("#txt_querypoi").val(name);
+      $("#btn_querypoi").trigger("click");
+    }
+
+    //===================涓庡悗鍙颁氦浜�========================
+
+    //鏄剧ず鏅鸿兘鎻愮ず鎼滅储缁撴灉
+    autoTipList(text, queryEx) {
+      //杈撳叆缁忕含搴︽暟瀛楁椂
+      if (this.isLonLat(text)) {
+        return;
+      }
+
+      //鏌ヨ澶栭儴widget
+      if (this.hasExWidget() && queryEx) {
+        this.autoExTipList(text);
+        return;
+      }
+      //鏌ヨ澶栭儴widget
+
+      //鎼滅储鎻愮ず
+      this._queryPoi.autoTip({
+        text: text,
+        city: this.address?.city,
+        location: this.map.getCenter(),
+        success: (result) => {
+          var inhtml = "";
+          var pois = result.list;
+          for (var index = 0; index < pois.length; index++) {
+            var name = pois[index].name;
+            // var num = pois[index].num;
+            // if (num > 0) continue;
+
+            inhtml += "<li><i class='fa fa-search'></i><a href=\"javascript:queryBaiduPOIWidget.autoSearch('" + name + "');\">" + name + "</a></li>";
+          }
+          if (inhtml.length > 0) {
+            $("#querybar_ul_autotip").html(inhtml);
+            $("#querybar_autotip_view").show();
+          }
+        },
+      });
+    }
+
+    // 鏍规嵁杈撳叆妗嗗唴瀹癸紝鏌ヨ鏄剧ず鍒楄〃
+    strartQueryPOI(text, queryEx) {
+      if (text.length == 0) {
+        toastr.warning("璇疯緭鍏ユ悳绱㈠叧閿瓧锛�");
+        return;
+      }
+
+      // TODO:鏍规嵁鏂囨湰妗嗚緭鍏ュ唴瀹�,浠庢暟鎹簱妯$硦鏌ヨ鍒版墍鏈夊尮閰嶇粨鏋滐紙鍒嗛〉鏄剧ず锛�
+      this.addHistory(text);
+
+      this.hideAllQueryBarView();
+
+      //杈撳叆缁忕含搴︽暟瀛楁椂
+      if (this.isLonLat(text)) {
+        this.centerAtLonLat(text);
+        return;
+      }
+
+      //鏌ヨ澶栭儴widget
+      if (this.hasExWidget() && queryEx) {
+        var qylist = this.queryExPOI(text);
+        return;
+      }
+      //鏌ヨ澶栭儴widget
+
+      this.thispage = 1;
+      this.queryText = text;
+
+      this.query_city = this.address?.city;
+      // this.query_location = this.map.getCenter()
+      // this.query_radius = this.map.camera.positionCartographic.height //鍗曚綅锛氱背
+
+      this.queryTextByServer();
+    }
+    queryTextByServer() {
+      //鏌ヨ鑾峰彇鏁版嵁
+      this._queryPoi.queryText({
+        text: this.queryText,
+        count: this.pageSize,
+        page: this.thispage - 1,
+        city: this.query_city,
+        // location: this.query_location,
+        // radius: this.query_radius,
+        success: (result) => {
+          if (!this.isActivate) {
+            return;
+          }
+          this.showPOIPage(result.list, result.allcount);
+        },
+      });
+    }
+
+    //===================鏄剧ず鏌ヨ缁撴灉澶勭悊========================
+    showPOIPage(data, counts) {
+      // count -- 鏄剧ず鎼滅储缁撴灉鐨勬暟閲忥紱data -- 缁撴灉鐨勫睘鎬э紝濡傚湴鍧�鐢佃瘽绛�
+
+      if (counts < data.length) {
+        counts = data.length;
+      }
+      this.allpage = Math.ceil(counts / this.pageSize);
+
+      var inhtml = "";
+      if (counts == 0) {
+        inhtml += '<div class="querybar-page"><div class="querybar-fl">娌℃湁鎵惧埌"<strong>' + this.queryText + '</strong>"鐩稿叧缁撴灉</div></div>';
+      } else {
+        this.objResultData = this.objResultData || {};
+        for (var index = 0; index < data.length; index++) {
+          var item = data[index];
+          var startIdx = (this.thispage - 1) * this.pageSize;
+          item.index = startIdx + (index + 1);
+
+          var _id = index;
+          var _mc;
+          if (item.detail_info && item.detail_info.detail_url) {
+            _mc = '<a href="' + item.detail_info.detail_url + '"  target="_black" style="color: #ffffff; ">' + item.name + "</a>";
+          } else {
+            _mc = item.name;
           }
 
-          //搴曢儴淇℃伅
-          inhtml += '<div class="querybar-page"><div class="querybar-fl">鎵惧埌<strong>' + this.counts + '</strong>鏉$粨鏋�</div>' + _fyhtml + '</div>'
-        }
-        $('#querybar_resultlist_view').html(inhtml)
-        $('#querybar_resultlist_view').show()
+          inhtml +=
+            '<div class="querybar-site" onclick="queryBaiduPOIWidget.showDetail(\'' +
+            _id +
+            '\')"> <div class="querybar-sitejj"> <h3>' +
+            item.index +
+            "銆�" +
+            _mc +
+            "</h3> <p>" +
+            (item.address || "") +
+            "</p> </div> </div>";
 
-        this.showPOIArr(this.arrdata)
-        if (this.counts == 1) {
-          this.showDetail('0')
-        }
-      }
-      showFirstPage() {
-        this.thispage = 1
-        this.queryPOI()
-      }
-      showNextPage() {
-        this.thispage = this.thispage + 1
-        if (this.thispage > this.allpage) {
-          this.thispage = this.allpage
-          toastr.warning('褰撳墠宸叉槸鏈�鍚庝竴椤典簡')
-          return
-        }
-        this.queryPOI()
-      }
-
-      showPretPage() {
-        this.thispage = this.thispage - 1
-        if (this.thispage < 1) {
-          this.thispage = 1
-          toastr.warning('褰撳墠宸叉槸绗竴椤典簡')
-          return
-        }
-        this.queryPOI()
-      }
-      //鐐瑰嚮鍗曚釜缁撴灉,鏄剧ず璇︾粏
-      showDetail(id) {
-        var item = this.objResultData[id]
-        this.flyTo(item)
-      }
-      clearLayers() {
-        this.graphicLayer.closePopup()
-        this.graphicLayer.clear()
-      }
-      showPOIArr(arr) {
-        this.clearLayers()
-
-        arr.forEach((item) => {
-          var jd = Number(item.x)
-          var wd = Number(item.y)
-          if (isNaN(jd) || isNaN(wd)) {
-            return
-          }
-
-          item.x = jd
-          item.y = wd
-
-          //娣诲姞瀹炰綋
-          var graphic = new mars3d.graphic.PointEntity({
-            position: Cesium.Cartesian3.fromDegrees(jd, wd),
-            style: {
-              pixelSize: 10,
-              color: '#3388ff',
-              outline: true,
-              outlineColor: '#ffffff',
-              outlineWidth: 2,
-              scaleByDistance: new Cesium.NearFarScalar(1000, 1, 1000000, 0.1),
-              clampToGround: true, //璐村湴
-              visibleDepth: false, //鏄惁琚伄鎸�
-              label: {
-                text: item.name,
-                font_size: 20,
-                color: 'rgb(240,255,255)',
-                outline: true,
-                outlineWidth: 2,
-                outlineColor: Cesium.Color.BLACK,
-                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
-                verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
-                pixelOffsetY: -10, //鍋忕Щ閲�
-                distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 200000),
-                clampToGround: true, //璐村湴
-                visibleDepth: false, //鏄惁琚伄鎸�
-              },
-            },
-            attr: item,
-          })
-          this.graphicLayer.addGraphic(graphic)
-
-          item._graphic = graphic
-        })
-
-        if (arr.length > 1) {
-          this.graphicLayer.flyTo()
-        }
-      }
-      flyTo(item) {
-        var graphic = item._graphic
-        if (graphic == null) {
-          window.toastr.warning(item.name + ' 鏃犵粡绾害鍧愭爣淇℃伅锛�')
-          return
+          this.objResultData[_id] = item;
         }
 
-        this.map.flyToGraphic(graphic, { radius: 2000 })
-
-        setTimeout(() => {
-          this.graphicLayer.openPopup(graphic)
-        }, 3000)
-      }
-
-      //===================鍧愭爣瀹氫綅澶勭悊========================
-      isLonLat(text) {
-        var reg = /^-?((0|1?[0-7]?[0-9]?)(([.][0-9]*)?)|180(([.][0]*)?)),-?((0|[1-8]?[0-9]?)(([.][0-9]*)?)|90(([.][0]*)?))$/ /*瀹氫箟楠岃瘉琛ㄨ揪寮�*/
-        return reg.test(text) /*杩涜楠岃瘉*/
-      }
-      centerAtLonLat(text) {
-        var arr = text.split(',')
-        if (arr.length != 2) {
-          return
+        //鍒嗛〉淇℃伅
+        var _fyhtml;
+        if (this.allpage > 1) {
+          _fyhtml =
+            '<div class="querybar-ye querybar-fr">' +
+            this.thispage +
+            "/" +
+            this.allpage +
+            '椤�  <a href="javascript:queryBaiduPOIWidget.showFirstPage()">棣栭〉</a> <a href="javascript:queryBaiduPOIWidget.showPretPage()">&lt;</a>  <a href="javascript:queryBaiduPOIWidget.showNextPage()">&gt;</a> </div>';
+        } else {
+          _fyhtml = "";
         }
 
-        var jd = Number(arr[0])
-        var wd = Number(arr[1])
+        //搴曢儴淇℃伅
+        inhtml += '<div class="querybar-page"><div class="querybar-fl">鎵惧埌<strong>' + counts + "</strong>鏉$粨鏋�</div>" + _fyhtml + "</div>";
+      }
+      $("#querybar_resultlist_view").html(inhtml);
+      $("#querybar_resultlist_view").show();
+
+      this.showPOIArr(data);
+      if (counts == 1) {
+        this.showDetail("0");
+      }
+    }
+    showFirstPage() {
+      this.thispage = 1;
+      this.queryTextByServer();
+    }
+    showNextPage() {
+      this.thispage = this.thispage + 1;
+      if (this.thispage > this.allpage) {
+        this.thispage = this.allpage;
+        toastr.warning("褰撳墠宸叉槸鏈�鍚庝竴椤典簡");
+        return;
+      }
+      this.queryTextByServer();
+    }
+
+    showPretPage() {
+      this.thispage = this.thispage - 1;
+      if (this.thispage < 1) {
+        this.thispage = 1;
+        toastr.warning("褰撳墠宸叉槸绗竴椤典簡");
+        return;
+      }
+      this.queryTextByServer();
+    }
+    //鐐瑰嚮鍗曚釜缁撴灉,鏄剧ず璇︾粏
+    showDetail(id) {
+      var item = this.objResultData[id];
+      this.flyTo(item);
+    }
+    clearLayers() {
+      this.graphicLayer.closePopup();
+      this.graphicLayer.clear();
+    }
+    showPOIArr(arr) {
+      this.clearLayers();
+
+      arr.forEach((item) => {
+        var jd = Number(item.x);
+        var wd = Number(item.y);
         if (isNaN(jd) || isNaN(wd)) {
-          return
+          return;
         }
 
-        this.map.setCameraView({ x: jd, y: wd, minz: 2500 })
+        item.x = jd;
+        item.y = wd;
 
         //娣诲姞瀹炰綋
         var graphic = new mars3d.graphic.PointEntity({
           position: Cesium.Cartesian3.fromDegrees(jd, wd),
           style: {
-            color: '#3388ff',
             pixelSize: 10,
+            color: "#3388ff",
             outline: true,
-            outlineColor: '#ffffff',
+            outlineColor: "#ffffff",
             outlineWidth: 2,
             scaleByDistance: new Cesium.NearFarScalar(1000, 1, 1000000, 0.1),
             clampToGround: true, //璐村湴
             visibleDepth: false, //鏄惁琚伄鎸�
+            label: {
+              text: item.name,
+              font_size: 20,
+              color: "rgb(240,255,255)",
+              outline: true,
+              outlineWidth: 2,
+              outlineColor: Cesium.Color.BLACK,
+              horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
+              verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
+              pixelOffsetY: -10, //鍋忕Щ閲�
+              distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 200000),
+              clampToGround: true, //璐村湴
+              visibleDepth: false, //鏄惁琚伄鎸�
+            },
           },
-        })
-        this.graphicLayer.addGraphic(graphic)
+          attr: item,
+        });
+        this.graphicLayer.addGraphic(graphic);
 
-        graphic.bindPopup(`<div class="mars-popup-titile">鍧愭爣瀹氫綅</div>
+        item._graphic = graphic;
+      });
+
+      if (arr.length > 1) {
+        this.graphicLayer.flyTo();
+      }
+    }
+    flyTo(item) {
+      var graphic = item._graphic;
+      if (graphic == null) {
+        window.toastr.warning(item.name + " 鏃犵粡绾害鍧愭爣淇℃伅锛�");
+        return;
+      }
+
+      this.map.flyToGraphic(graphic, { radius: 2000 });
+
+      setTimeout(() => {
+        this.graphicLayer.openPopup(graphic);
+      }, 3000);
+    }
+
+    //===================鍧愭爣瀹氫綅澶勭悊========================
+    isLonLat(text) {
+      var reg = /^-?((0|1?[0-7]?[0-9]?)(([.][0-9]*)?)|180(([.][0]*)?)),-?((0|[1-8]?[0-9]?)(([.][0-9]*)?)|90(([.][0]*)?))$/; /*瀹氫箟楠岃瘉琛ㄨ揪寮�*/
+      return reg.test(text); /*杩涜楠岃瘉*/
+    }
+    centerAtLonLat(text) {
+      var arr = text.split(",");
+      if (arr.length != 2) {
+        return;
+      }
+
+      var jd = Number(arr[0]);
+      var wd = Number(arr[1]);
+      if (isNaN(jd) || isNaN(wd)) {
+        return;
+      }
+
+      this.map.setCameraView({ x: jd, y: wd, minz: 2500 });
+
+      //娣诲姞瀹炰綋
+      var graphic = new mars3d.graphic.PointEntity({
+        position: Cesium.Cartesian3.fromDegrees(jd, wd),
+        style: {
+          color: "#3388ff",
+          pixelSize: 10,
+          outline: true,
+          outlineColor: "#ffffff",
+          outlineWidth: 2,
+          scaleByDistance: new Cesium.NearFarScalar(1000, 1, 1000000, 0.1),
+          clampToGround: true, //璐村湴
+          visibleDepth: false, //鏄惁琚伄鎸�
+        },
+      });
+      this.graphicLayer.addGraphic(graphic);
+
+      graphic.bindPopup(`<div class="mars-popup-titile">鍧愭爣瀹氫綅</div>
               <div class="mars-popup-content" >
                 <div><label>缁忓害</label> ${jd}</div>
                 <div><label>绾害</label>${wd}</div>
-              </div>`)
+              </div>`);
 
-        setTimeout(() => {
-          graphic.openPopup()
-        }, 3000)
-      }
-
-      //===================鍘嗗彶璁板綍鐩稿叧========================
-      showHistoryList() {
-        $('#querybar_histroy_view').hide()
-
-        var laststorage = haoutil.storage.get(this.storageName) //璇诲彇storage鍊�
-        if (laststorage == null) {
-          return
-        }
-
-        this.arrHistory = eval(laststorage)
-        if (this.arrHistory == null || this.arrHistory.length == 0) {
-          return
-        }
-
-        var inhtml = ''
-        for (var index = this.arrHistory.length - 1; index >= 0; index--) {
-          var item = this.arrHistory[index]
-          inhtml += "<li><i class='fa fa-history'/><a href=\"javascript:queryBaiduPOIWidget.autoSearch('" + item + '\');">' + item + '</a></li>'
-        }
-        $('#querybar_ul_history').html(inhtml)
-        $('#querybar_histroy_view').show()
-      }
-
-      clearHistory() {
-        this.arrHistory = []
-        haoutil.storage.del(this.storageName)
-
-        $('#querybar_ul_history').html('')
-        $('#querybar_histroy_view').hide()
-      }
-
-      //璁板綍鍘嗗彶鍊�
-      addHistory(data) {
-        this.arrHistory = []
-        var laststorage = haoutil.storage.get(this.storageName) //璇诲彇storage鍊�
-        if (laststorage != null) {
-          this.arrHistory = eval(laststorage)
-        }
-        //鍏堝垹闄や箣鍓嶇浉鍚岃褰�
-        this.arrHistory.remove(data)
-
-        this.arrHistory.push(data)
-
-        if (this.arrHistory.length > 10) {
-          this.arrHistory.splice(0, 1)
-        }
-
-        laststorage = JSON.stringify(this.arrHistory)
-        haoutil.storage.add(this.storageName, laststorage)
-      }
-
-      //======================鏌ヨ闈炵櫨搴oi锛岃仈鍚堟煡璇㈠鐞�=================
-      //澶栭儴widget鏄惁瀛樺湪鎴栧惎鐢�
-      hasExWidget() {
-        if (window['queryBarWidget'] == null) {
-          return false
-        } else {
-          this.exWidget = window.queryBarWidget
-          return true
-        }
-      }
-      autoExTipList(text) {
-        this.exWidget.autoTipList(text, () => {
-          this.autoTipList(text, false)
-        })
-      }
-      //璋冪敤澶栭儴widget杩涜鏌ヨ
-      queryExPOI(text) {
-        var layer = this.graphicLayer
-
-        this.exWidget.strartQueryPOI(text, layer, () => {
-          this.strartQueryPOI(text, false)
-        })
-      }
+      setTimeout(() => {
+        graphic.openPopup();
+      }, 3000);
     }
 
-    //娉ㄥ唽鍒皐idget绠$悊鍣ㄤ腑銆�
-    window.queryBaiduPOIWidget = mars3d.widget.bindClass(MyWidget)
+    //===================鍘嗗彶璁板綍鐩稿叧========================
+    showHistoryList() {
+      $("#querybar_histroy_view").hide();
 
-    //姣忎釜widet涔嬮棿閮芥槸鐩存帴寮曞叆鍒癷ndex.html涓紝浼氬瓨鍦ㄥ郊姝ゅ懡鍚嶅啿绐侊紝鎵�浠ラ棴鍖呭鐞嗕笅銆�
-  })(window, mars3d)
+      localforage.getItem(this.storageName).then((laststorage) => {
+        if (laststorage == null) {
+          return;
+        }
+        this.arrHistory = eval(laststorage);
+        if (this.arrHistory == null || this.arrHistory.length == 0) {
+          return;
+        }
+
+        var inhtml = "";
+        for (var index = this.arrHistory.length - 1; index >= 0; index--) {
+          var item = this.arrHistory[index];
+          inhtml += "<li><i class='fa fa-history'/><a href=\"javascript:queryBaiduPOIWidget.autoSearch('" + item + "');\">" + item + "</a></li>";
+        }
+        $("#querybar_ul_history").html(inhtml);
+        $("#querybar_histroy_view").show();
+      });
+    }
+
+    clearHistory() {
+      this.arrHistory = [];
+      localforage.removeItem(this.storageName);
+
+      $("#querybar_ul_history").html("");
+      $("#querybar_histroy_view").hide();
+    }
+
+    //璁板綍鍘嗗彶鍊�
+    addHistory(data) {
+      this.arrHistory = [];
+      localforage.getItem(this.storageName).then((laststorage) => {
+        if (laststorage != null) {
+          this.arrHistory = eval(laststorage);
+        }
+        //鍏堝垹闄や箣鍓嶇浉鍚岃褰�
+        haoutil.array.remove(this.arrHistory, data);
+        this.arrHistory.push(data);
+
+        if (this.arrHistory.length > 10) {
+          this.arrHistory.splice(0, 1);
+        }
+        localforage.setItem(this.storageName, this.arrHistory);
+      });
+    }
+
+    //======================鏌ヨ闈炵櫨搴oi锛岃仈鍚堟煡璇㈠鐞�=================
+    //澶栭儴widget鏄惁瀛樺湪鎴栧惎鐢�
+    hasExWidget() {
+      if (window["queryBarWidget"] == null) {
+        return false;
+      } else {
+        this.exWidget = window.queryBarWidget;
+        return true;
+      }
+    }
+    autoExTipList(text) {
+      this.exWidget.autoTipList(text, () => {
+        this.autoTipList(text, false);
+      });
+    }
+    //璋冪敤澶栭儴widget杩涜鏌ヨ
+    queryExPOI(text) {
+      var layer = this.graphicLayer;
+
+      this.exWidget.strartQueryPOI(text, layer, () => {
+        this.strartQueryPOI(text, false);
+      });
+    }
+  }
+
+  //娉ㄥ唽鍒皐idget绠$悊鍣ㄤ腑銆�
+  window.queryBaiduPOIWidget = mars3d.widget.bindClass(MyWidget);
+
+  //姣忎釜widet涔嬮棿閮芥槸鐩存帴寮曞叆鍒癷ndex.html涓紝浼氬瓨鍦ㄥ郊姝ゅ懡鍚嶅啿绐侊紝鎵�浠ラ棴鍖呭鐞嗕笅銆�
+})(window, mars3d);

--
Gitblit v1.9.1