首页新闻找找看学习计划

我在 .net后台代码上调用js 的方法,给js onload = "initialize()"

0
悬赏园豆:80 [已关闭问题]

js 方法中是对 GoogleMap 的API的调用,我先是固定了 地图的 坐标,

 我想 选中下拉框选定省份以后,  给地图中心坐标重新赋值到省份的位置,  所以我选中好省份以后,要给 js 方法赋值...  我知不知道怎么调用  js方法,诸位大哥,谢谢了!

代码
<script type="text/javascript">
    var req = null;
    var res = "";
    var map=null;   
    function processReqChange( ) {
        if (req.readyState == 4 && req.status == 200 ) {           
            var c=eval(req.responseText);
            for(var i=0;i<c.length;i++){
                //将叠加层添加到地图中                                                            
                var latlng=new GLatLng(c[i][0],c[i][1]);                                 
                  function createMarker(point) {                
                 // 为所有标记创建指定阴影、图标尺寸灯的基础图标
                    var baseIcon = new GIcon();
                    baseIcon.shadow = "http://www.google.cn/mapfiles/shadow50.png";
                    //baseIcon.iconSize = new GSize(100, 80);      //图标前景图像的像素大小
                    //baseIcon.shadowSize = new GSize(43, 27);    //阴影图像的像素大小。
                    baseIcon.iconAnchor = new GPoint(9, 34);
                    baseIcon.infoWindowAnchor = new GPoint(2, 2);                   
                   var letteredIcon = new GIcon(baseIcon);
                   var ImageUrl=c[i][5];
                   //alert(ImageUrl);
                  letteredIcon.image = ImageUrl;
                  // 设置 GMarkerOptions 对象
                  markerOptions = { icon:letteredIcon };
                  var marker = new GMarker(point, markerOptions);
                  var letter =c[i][2];
                  var mapurl=c[i][4];                           
                  GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml("这里是<b>" + letter + "</b>"+mapurl);
                  });
                  return marker;
                }
                map.addOverlay(createMarker(latlng));
                }
        }
    }
    function loadXMLDoc( url ) {
      if(window.XMLHttpRequest) {
        try { req = new XMLHttpRequest(); } catch(e) { req = false; }
      }
      else if(window.ActiveXObject)
      {
        try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {
        try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; } }
      }
      if(req) {     
        req.onreadystatechange = function() { processReqChange(  ); };
        req.open("GET", url, true);//document.write(url);
       
        req.send("");
      }
    }
    function initialize() {
      if (GBrowserIsCompatible()) {//判断浏览器是否支持Google API库
        map = new GMap2(document.getElementById("map_canvas")); //生成一个地图
        map.setCenter(new GLatLng(30.39,104.04), 4);         //设定居中坐标,13级显示....
        var smallMapControl = new GSmallMapControl();           //地图的放大和缩小(只是生成却没有添加)
        smallMapControl
        //设定屏幕的左右位置
        var topLeft = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,10));        //设置 屏幕坐标 -- 左上角               
        var bottomLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10,10)); //设置 屏幕坐标到 -- 左下角
        //在地图上添加放大和缩小到屏幕的左上角
        map.addControl(smallMapControl, topLeft);
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();                //返回矩形西南角的点
        var northEast = bounds.getNorthEast();                //返回矩形东北角的点
        var lngSpan = northEast.lng() - southWest.lng();      //中间坐标
        GEvent.addListener(map,"zoomend", function() {
          document.getElementById("message").innerHTML = map.getZoom();   
     
      loadXMLDoc("One.ashx?a1="+southWest.lat()+"&a2="+northEast.lat()+"&b1="+southWest.lng()+"&b2="+northEast.lng()+"&zoom="+map.getZoom());
        });
         loadXMLDoc("One.ashx?a1="+southWest.lat()+"&a2="+northEast.lat()+"&b1="+southWest.lng()+"&b2="+northEast.lng()+"&zoom="+map.getZoom());
      }     
    }
    </script>

脚踏祥云的主页 脚踏祥云 | 初学一级 | 园豆:120
提问于:2009-08-31 17:49
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册