真善美

勇于承担责任; 如果你做不到,要提前跟别人说明,不要等到事情发生后再解释。

  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 真善美 阅读(1217) 评论(0)  编辑  收藏 所属分类: 其它