soso地图开发问题,拖动地图浏览器停滞

张江华 发布于 2013/01/11 08:06
阅读 421
收藏 0

希望哪位高手帮我解决一下这个问题,想了好多天了,编程思路应该没什么问题,不知道为什么一拖动地图鼠标点击浏览器窗口就没反应了,只有再点击一下下面的浏览器任务栏才能将浏览器激活。直接调用soso地图代码没问题,但是加上从数据库中提取信息动态显示就出现这个问题,哪位大虾帮帮忙吧

<%@ page language="java" import="java.util.*,com.security.factory.*,com.security.vo.*,com.zjx.utils.*" pageEncoding="UTF-8"%>

<!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=utf-8" />
<title>地图界面</title>
</head>
<link rel="stylesheet" type="text/css" href="images/style.css"/>
<script charset="utf-8" src="http://api.map.soso.com/v1.0/main.js"></script>
<script>
var map;
var geocoder,map,marker = null;
var init = function() {

 //设置地图中心位置
     map = new soso.maps.Map(document.getElementById("container"),{
        center: new soso.maps.LatLng(35.067112289388568,110.9836306762695),
        zoomLevel: 12
    });

      var infoWin = new soso.maps.InfoWindow({
        map: map
    });
   
     geolocation = new soso.maps.Geolocation();
    var latlngqq=[];
     var markerqq=[];
    <%List all=(List)DAOFactory.getQyjbxxDAOInstance().searchAll("where sfsh=1");
     String qymc="";
     for (int i = 0; i < all.size(); i++) {
     Qyjbxx obj1 = (Qyjbxx) all.get(i);
       if(obj1!=null){
       %>
        latlngqq[<%=i%>]= new soso.maps.LatLng(<%=obj1.getLatitude().toString() %>,<%=obj1.getLongitude().toString() %>);
        markerqq[<%=i%>] = new soso.maps.Marker({
                position: latlngqq[<%=i%>],
                map: map
            });
            <%qymc=obj1.getQymc();
           %>
            soso.maps.Event.addListener(markerqq[<%=i%>], 'click', function() {
                infoWin.open('<div style="text-align:center;white-space:'+
                'nowrap;margin:10px;"> ' +
                '<a href="qyjbxx_ca.jsp?qybm='+<%=obj1.getQybm() %>+'">'+'<%=qymc%></a><br><a href="servlet/ZlytjServlet?flag=6&qybm='+<%=obj1.getQybm() %>+'">查看质量月统计</a>'+ ' </div>', markerqq[<%=i%>]);
            });
       <%}}%>  
      
 
  //获取点击点坐标
 soso.maps.Event.addListener(map, 'click', function(event) {
        alert('您点击的位置为: [' + event.latLng.getLat() + ', ' +
      event.latLng.getLng() + ']');
    });
 
    geocoder = new soso.maps.Geocoder();
  //添加导航控件
 var navctrl = new __MapNS__.NavigationControl({
        map: map,
        margin: new __MapNS__.Size(0, 10),
        zoomLevelTips:null
    }); 
 
  
}
//改变地图类型
function changeMapType(maptype){
    switch(maptype){
        case 'roadmap':
            map.setMapTypeId(soso.maps.MapTypeId.ROADMAP);
        break;
        case 'satellite':
            map.setMapTypeId(soso.maps.MapTypeId.SATELLITE);
        break;
        case 'hybrid':
            map.setMapTypeId(soso.maps.MapTypeId.HYBRID);
        break;
    }
   }
   //地址解析
function codeAddress() {
    var address = document.getElementById("address").value;
    geocoder.geocode({'address': address}, function(results, status) {
        if (status == soso.maps.GeocoderStatus.OK) {
            map.setCenter(results.location);
            if (marker != null) {
                marker.setMap(null);
            }
            marker = new soso.maps.Marker({
                map: map,
                position:results.location
            });
           // sendRequest();
   //获取标注点坐标
   //alert(marker.getPosition().getLat()+' ,'+marker.getPosition().getLng());
         //location.replace('servlet/DistrictServlet?flag=2'+'"&getlng="'+marker.getPosition().getLng()+'"&getlat="'+marker.getPosition().getLat()+');
           //window.location.href="cope.jsp?flag=2&getlng="+marker.getPosition().getLng()+"&getlat=" + marker.getPosition().getLat()
       
        } else {
            alert("检索没有结果,原因: " + status);
        }
    });  
 
}

 var XMLHttpReq;
  //创建XMLHttpRequest对象      
    function createXMLHttpRequest() {
  if(window.XMLHttpRequest) { //Mozilla 浏览器
   XMLHttpReq = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) { // IE浏览器
   try {
    XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
    try {
     XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {}
   }
  }
 }
 //发送请求函数
 function sendRequest() {
  createXMLHttpRequest();
        var url = "auto.jsp?flag=2&getlng="+marker.getPosition().getLng()+"&getlat=" + marker.getPosition().getLat();
  XMLHttpReq.open("GET", url, true);
  XMLHttpReq.onreadystatechange = processResponse;//指定响应函数
  XMLHttpReq.send(null);  // 发送请求
 }
 // 处理返回信息函数
    function processResponse() {
     if (XMLHttpReq.readyState == 4) { // 判断对象状态
         if (XMLHttpReq.status == 200) { // 信息已经成功返回,开始处理信息
    DisplayHot();
    //setTimeout("sendRequest()", 1000);
            } else { //页面不正常
                window.alert("您所请求的页面有异常。");
            }
        }
    }
  
 function next(){
    window.location.href="dingwei.jsp?cellnumber="+XMLHttpReq.responseXML.getElementsByTagName("cellNumber")[0].firstChild.nodeValue;
       
 }
 function locate(lat1,lng2){
    var lat = parseFloat(lat1);
    var lng = parseFloat(lng2);
    var latLng = new soso.maps.LatLng(lat, lng);
    var request = {
        keyword : latLng,
        locationMode : soso.maps.LocationMode.LATLNG //可选参数,可以不用设置
    }
  
    geolocation.position(request, function(results, status) {
       
           if (status == soso.maps.GeolocationStatus.OK) {
            map.setCenter(results.latLng);
      alert(results.latLng);
      var anchor = new soso.maps.Point(6, 6),
        size = new soso.maps.Size(24, 24),
        icon = new soso.maps.MarkerImage('img/center.gif', size, anchor);
      var marker = new soso.maps.Marker({
                icon: icon,
                map: map,
                position:results.location
            });
           alert("定位结束");
        } else {
            alert("检索没有结果,原因: " + status);
        }
    });
   
    alert("定位成功");
 }

</script>
<body onLoad="init()">
<div id="index_main">
     <div id="banner"><img src="images/banner.jpg" width="1000" height="100" /></div>
        <div><hr /></div>
        <div id="index_content">
         <ul>
             <li id="index_content_left">
                  <table class="table1" border="0" cellspacing="0" cellpadding="0">
                   <tr>
                     <td><img src="images/matix1.jpg" width="650" height="33" /></td>
                   </tr>
                   <tr>
                     <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                       <tr>
                         <td width="10" style="background-image:url(images/matix2_l.jpg); background-repeat:repeat-y;">&nbsp;
                           
                            </td>
                         <td><div style="width:629px;height:400px" id="container"></div></td>
                         <td width="11" style="background-image:url(images/matix2_r.jpg); background-repeat:repeat-y;">&nbsp;</td>
                       </tr>
                     </table></td>
                   </tr>
                 <tr>
                     <td><img src="images/matix3.jpg" width="648" height="9" /></td>
                   </tr>
                    <tr>
                     <td style="padding-top:10px;">
                         
                         <button class='btn' onclick='changeMapType("roadmap")'>普通街道</button>
          <button class='btn' onclick='changeMapType("satellite")'>卫星地图</button>
          <button class='btn' style="position:relative;top:1px; _width:100px;" onclick='changeMapType("hybrid")'>卫星地图(路网)</button>
                            &nbsp;
                            <input id="address" type="textbox" style="position:relative;top:1px;"  class="textbox1" size="32" value="中国,太原,万柏林区,智诚天和园"/>
       <button onclick="codeAddress()" class="btn"  style="position:relative;top:1px;" >搜&nbsp;&nbsp;索</button>
                        </td>
                   </tr>
                 </table>
                </li>
                <li id="index_content_right">
     <table >
 
  <tr>
               <th height="27" style="background-image:url(images/table_1.jpg); font-size:
                      14px; background-position:bottom; padding-top:2px;" colspan=2 >企业信息</th>
                </tr>

     <tr>
                            <td width="462">企业名</td>
                            <td width="122">操作</td>
                          </tr>
  
    <% 
      String jspUrl="index.jsp?";//分页要跳转的页面
      
  int currentPage=Integer.parseInt(request.getParameter("page"));//当前页
  int pageSize=25;//每页显示的条数 
     if (all.size()>0) {
      Qyjbxx obj = new Qyjbxx();
      PagingFuction pf = new PagingFuction();//分页处理类
      int pageNum=pf.getPageNum(all.size(),pageSize);//总页数 
      currentPage=pf.getCurrentPage(currentPage,pageNum);
      for (int i = 0; i < pf.getPageSize(currentPage,pageSize,all.size(),pageNum); i++) {  
       obj = (Qyjbxx) all.get(pf.getInitRecord(currentPage,pageSize) + i);
       if(obj!=null)
       {
    %>                     
     <tr>
                            <td ><a href="qyjbxx_ca.jsp?qybm=<%=obj.getQybm() %>"><%=obj.getQymc() %></td>
                            <td><a href="#" onclick="locate(<%=obj.getLatitude() %>,<%=obj.getLongitude() %>)">定位</td>
                          </tr>
                          <%}} %>
                <tr bgcolor="#f4f4f4">
             
              <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="wenzi12">
                  <tr  width="100%">
                    <td height="30"></td>
                    <td> 第&nbsp;<%=currentPage%>&nbsp;页 &nbsp;&nbsp;</td>
                    <td>共&nbsp;<%=pageNum%>&nbsp;页 &nbsp;&nbsp;</td>
                    <td><a href="<%=jspUrl%>page=1">首&nbsp;&nbsp;页</a> &nbsp;&nbsp;</td>
                    <td><<a href="<%=jspUrl%>page=<%=currentPage - 1%>">上一页</a>&nbsp;&nbsp;</td>
                    <td><a href="<%=jspUrl%>page=<%=currentPage + 1%>">下一页</a>>&nbsp;&nbsp;<a href="<%=jspUrl%>page=<%=pageNum%>">尾&nbsp;&nbsp;页 </a></td>
                  </tr>
                
                
                <%
     }else{
    %>
        <tr bgcolor="#f4f4f4">
              <td height="23" colspan="2" class="12hh"><div align="center">目前无企业</div></td>
            </tr>
               <%} %>
              </table>
            </tr>
                
                          
   
    </table>
   
                
                   
                 
                
                </li>
            </ul>
  </div>
       
    </div>
</body>
</html>

 

加载中
返回顶部
顶部