真善美

          勇于承擔責任; 如果你做不到,要提前跟別人說明,不要等到事情發生后再解釋。

            BlogJava :: 首頁 ::  :: 聯系 :: 聚合  :: 管理 ::
            55 隨筆 :: 0 文章 :: 29 評論 :: 0 Trackbacks

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
          <html xmlns="http://www.w3.org/1999/xhtml">  
          <head>  
          <meta http-equiv="Content-Type" content="text/html; charset=GBK" />  
          <title>拉框查詢</title>  
           
          <script type="text/javascript" src="http://app.mapabc.com/apis?&t=ajaxmap&v=2.1.2&key=b0a7db0b3a30f944a21c3682064dc70ef5b738b062f6479a5eca39725798b1ee300bd8d5de3a4ae3|29e8ed1f7f6a97d8e99fc568cea6a7dc0ccd920856e07c0718b9885faf7551a18141699c81f526d7"></script>  
           
          <script type="text/javascript">  
          var mapObj=null;  
          function mapInit() {  
              var mapOptions = new MMapOptions();//構建地圖輔助類  
              mapOptions.zoom=13;//要加載的地圖的縮放級別  
              mapOptions.center=new MLngLat(116.397428,39.90923);//要加載的地圖的中心點經緯度坐標  
              mapOptions.toolbar = DEFAULT;//設置地圖初始化工具條  
              mapOptions.toolbarPos = new MPoint(15,15); //設置工具條在地圖上的顯示位置  
              mapOptions.overviewMap = SHOW; //設置鷹眼地圖的狀態,SHOW:顯示,HIDE:隱藏(默認)  
              mapOptions.scale = SHOW; //設置地圖初始化比例尺狀態,SHOW:顯示(默認),HIDE:隱藏。  
              mapOptions.returnCoordType = COORD_TYPE_OFFSET;//返回數字坐標  
              mapOptions.zoomBox = true;//鼠標滾輪縮放和雙擊放大時是否有紅框動畫效果。  
              mapObj=new MMap("map",mapOptions); //地圖初始化  
              mapObj.addEventListener(mapObj,ADD_OVERLAY,addOverlayEvent1);  
          }  
          var mlls ;  
          var regionTpyeSTR="";  
          var regionId="";  
          function qryAreaInfo()
          {   alert("查詢");
              var MSearch = new MPoiSearch();  
              MSearch.setCallbackFunction(searchSearchresult_CallBack);  
           MSearch.poiSearchByRegion(MOverlay.TYPE_RECTANGLE,aa,"","");
           alert("OK");

          var aa=new Array();
          function addOverlayEvent(param)
          {   alert("draw");
              mapObj.removeAllOverlays(); 
              mapObj.setCurrentMouseTool(MConstants.PAN_WHEELZOOM);   
              var overlay=mapObj.getOverlayById(param.overlayId);     
              aa=new MLngLats(overlay.lnglatArr);
              alert(aa);

          function addOverlayEvent1(param){  
              var keywords = document.getElementById("keyword").value;  
              var MSearch = new MPoiSearch();  
              var opt = new MPoiSearchOptions();  
              opt.recordsPerPage = 10;//每頁返回數據量,默認為10  
              opt.pageNum = 1;//當前頁數。  
              opt.dataType = "";//數據類別,該處為分詞查詢,只需要相關行業關鍵字即可  
              opt.dataSources = DS_BASE_ENPOI;//數據源,基礎+企業地標數據庫(默認)  
              MSearch.setCallbackFunction(searchSearchresult_CallBack);  
              var overlay=mapObj.getOverlayById(param.overlayId);  
              switch(overlay.TYPE){  
                  case "Polygon":  
                      mapObj.removeOverlayById(regionId);  
                      regionId=param.overlayId;  
                      MSearch.poiSearchByRegion(MOverlay.TYPE_POLYGON,new MLngLats(overlay.lnglatArr),keywords,opt);  
                  break;  
                  case "Rectangle":  
                      mapObj.removeOverlayById(regionId);  
                      regionId=param.overlayId;  
                      MSearch.poiSearchByRegion(MOverlay.TYPE_RECTANGLE,new MLngLats(overlay.lnglatArr),keywords,opt);  
                      aa=new MLngLats(overlay.lnglatArr);
                      alert(aa);
                  break;  
                  case "Circle":  
                      mapObj.removeOverlayById(regionId);  
                      var region = overlay.bounds.southWest.lngX+","+overlay.bounds.northEast.latY+","+overlay.bounds.northEast.lngX+","+overlay.bounds.southWest.latY;  
                      var arr1 = region.split(",");  
                      var regionArr=new Array();  
                      for(var i = 0 ;i<=arr1.length-2;){  
                              var mll =new MLngLat(arr1[i],arr1[i+1]);  
                              regionArr.push(mll);  
                              i=i+2;  
                      }  
                      regionId=param.overlayId;  
                      MSearch.poiSearchByRegion(MOverlay.TYPE_CIRCLE,new MLngLats(regionArr),keywords,opt);  
                  break;  
                  default:  
                  break;  
              }  
          }
          var resultCount=10;  
          function searchSearchresult_CallBack(data){  
              mapObj.setCurrentMouseTool(PAN_WHEELZOOM);  
              var resultStr="";  
              if(data.error_message != null){  
                  resultStr="查詢異常!"+data.error_message;  
              }else{  
              switch(data.message){  
                  case 'ok':  
                      var marker = new Array();  
                      if(data.searchresult.record==0){  
                          resultStr = "未查找到任何結果!<br />建議:<br />1.請確保所有字詞拼寫正確。<br />2.嘗試不同的關鍵字。<br />3.嘗試更寬泛的關鍵字。";  
                      }else{  
                          resultCount=data.searchresult.list.length;  
                          for (var i = 0; i < data.searchresult.list.length; i++) {  
                              resultStr += "<div id='divid"+(i)+"' onclick=\"javascript:var s=mapObj.setCenter(new MLngLat('"+ data.searchresult.list[i].x +"','"+ data.searchresult.list[i].y +"'));var t = mapObj.openOverlayTip('"+(i)+"');\" style=\"font-size: 13px;cursor:pointer;padding:2px 0 10px 5px;\">"+(i+1)+"、"+data.searchresult.list[i].name+"<br/>";  
           
                              resultStr += TipContents(data.searchresult.list[i].type,data.searchresult.list[i].address,data.searchresult.list[i].tel);  
                              resultStr += "<br />城市:"+data.searchresult.list[i].citycode + "<br \/></div>";  
           
                              var markerOption = new MMarkerOptions();  
                              markerOption.imageUrl ="http://code.mapabc.com/images/lan_1.png";  
           
                              var tipOption = new MTipOptions();  
                              tipOption.title=(i+1) + ". "+ data.searchresult.list[i].name;  
                              var tipC = "<br />"+TipContents(data.searchresult.list[i].type,data.searchresult.list[i].address,data.searchresult.list[i].tel)  
                              tipOption.content=tipC;//tip內容  
                              tipOption.borderStyle.thickness=2;  
                              tipOption.borderStyle.color= 0x005cb5;  
                              tipOption.borderStyle.alpha=1;  
                              tipOption.titleFontStyle.name="Arial";  
                              tipOption.titleFontStyle.size=12;  
                              tipOption.titleFontStyle.color= 0xffffff;  
                              tipOption.titleFontStyle.bold=true;  
                              tipOption.contentFontStyle.name="Arial";  
                              tipOption.contentFontStyle.size=13;  
                              tipOption.contentFontStyle.color= 0x000000 ;  
                              tipOption.contentFontStyle.bold=false;  
                              tipOption.fillStyle.color= 0xFFFFFF; //填充色  
                              tipOption.fillStyle.alpha=1;  
                              tipOption.titleFillStyle.color=0x005cb5;  
                              tipOption.titleFillStyle.alpha=1;  
           
                              markerOption.tipOption = tipOption;  
                              markerOption.canShowTip=true;  
                              var mar = new MMarker(new MLngLat(data.searchresult.list[i].x,data.searchresult.list[i].y),markerOption);  
                              mar.id=(i);  
                              marker.push(mar);  
                          }  
                          mapObj.addOverlays(marker,true);  
                          mapObj.addEventListener(mapObj,TIP_OPEN,openTip);  
                      }  
                  break;  
                  case 'error':  
                      resultStr= "<div class=\"default\"><div class=\"default_title\">網絡忙!請重新嘗試!</div><div class=\"d_link\"><div class=\"d_right\"></div><div class=\"suggest\"><strong>建議:</strong><br />如果您刷新頁后仍無法顯示結果,請過幾分鐘后再次嘗試或者與我們的服務人員聯系。<br />Email:service@mapabc.com <br />電話:400 810 0080</div></div></span>錯誤信息:"+data.message+"</div>";  
                  break;  
                  default:  
                      resultStr= "<div class=\"default\"><div class=\"default_title\">對不起!網絡繁忙!請稍后重新嘗試!</div><div class=\"d_link\"><div class=\"d_right\"></div><div class=\"suggest\"><strong>建議:</strong><br />如果您刷新頁后仍無法顯示結果,請過幾分鐘后再次嘗試或者與我們的服務人員聯系。<br />Email:service@mapabc.com <br />電話:400 810 0080</div></div></span>錯誤信息:"+data.message+"</div>";  
                  }  
              }  
              document.getElementById("result").innerHTML = resultStr;  
          }  
          function TipContents(type,address,tel){  
              if (type == "" || type == "undefined" || type == null || type == " undefined" || typeof type == "undefined") {  
                  type = "暫無";  
              }  
              if (address == "" || address == "undefined" || address == null || address == " undefined" || typeof address == "undefined") {  
                  address = "暫無";  
              }  
              if (tel == "" || tel == "undefined" || tel == null || tel == " undefined" || typeof address == "tel") {  
                  tel = "暫無";  
              }  
              var str ="地址:" + address + "<br>電話:" + tel + " <br>類型:"+type;  
              return str;  
          }  
          function openMarkerTipById1(pointid,thiss){  //根據id打開搜索結果點tip  
              thiss.style.background='#CFD6E8';  
              //mapObj.openOverlayTip(pointid);  
          }  
          function onmouseout_MarkerStyle(pointid,thiss) {//鼠標移開后點樣式恢復  
             thiss.style.background="";  
          }  
          function openTip(param){  
              var n = "divid"+(param.overlayId);  
              for (var i = 0; i < resultCount; ++i){  
                  var id="divid"+i;  
                  document.getElementById(id).style.background='';  
                  document.getElementById(id).onmouseout = function(){this.style.backgroundColor='';};  
              }  
              document.getElementById(n).style.background='#CFD6E8';  
              document.getElementById(n).onmouseout = function(){this.style.backgroundColor='#CFD6E8';};  
          }  
          </script>  
          </head>  
          <body onload="mapInit();">  
          <table width="989"  border="0" cellpadding="0" cellspacing="2" bgcolor="#DDDDDD">  
              <tr height="100%">  
                  <td rowspan="2" style="width:750px;height:600px;"><div id="map" style="height:600px; width:750px"></div></td>  
                  <td style="width:247px;border-left:1px solid #666;" valign="top" >  
                  <div style="padding:5px 0px 0px 5px;font-size:12px;height:290px">  
                      <div>拉框查詢<br />關鍵字:<input type="text" id="keyword" name="keyword" value="酒店"/><br />
                       <input type="button" onclick="mapObj.setCurrentMouseTool(DRAW_CIRCLE);" value="鼠標畫圓查詢" style="width:100px"/>
                       <input type="button" onclick="mapObj.setCurrentMouseTool(DRAW_RECTANGLE);" value="鼠標矩形查詢" style="width:100px"/>
                       <input type="button" onclick="mapObj.setCurrentMouseTool(DRAW_POLYGON);" value="鼠標畫多邊形查詢" style="width:120px"/></div>  
                      <div id="result" name="result" style="height:505px;overflow:auto;width:247px;margin-top:5px"></div>  
                 </div></td>  
             </tr>  
          </table>  
          </body>  
          </html> 

          posted on 2011-02-12 09:27 真善美 閱讀(1232) 評論(0)  編輯  收藏 所屬分類: 其它
          主站蜘蛛池模板: 丹凤县| 资溪县| 榕江县| 台东市| 三亚市| 乐平市| 夏河县| 武乡县| 呼和浩特市| 台东县| 城口县| 北辰区| 阿巴嘎旗| 乌审旗| 兰州市| 遵义县| 沂水县| 偏关县| 桂平市| 石门县| 左云县| 通渭县| 丘北县| 万全县| 上犹县| 西林县| 大化| 抚州市| 临高县| 铜梁县| 固安县| 南通市| 阳信县| 陆河县| 红原县| 平远县| 桂林市| 张家界市| 广元市| 民县| 巴彦淖尔市|