首页  >  文章  >  php教程  >  google地图 标记地图代码

google地图 标记地图代码

WBOY
WBOY原创
2016-06-08 17:27:481244浏览
<script>ec(2);</script>

nbsp;  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

   

标记地图

   

    function initialize(lng_x) {

   
  if (GBrowserIsCompatible()) {
          var map = new GMap2(document.getElementById("map_canvas"));//设置map对象
   map.addControl(new GSmallMapControl());//google 控件
  try{  
   
   var owin;
   if(window.opener){
    owin = window.opener;
   }else{
    owin = window.parent;
   }
   
   map_x=owin.document.getElementById("layout_map").value;
   //map_y=owin.document.getElementById("layout_map").value;
   map_z=owin.document.getElementById("layout_zoom").value*1; 
   
   if( map_x == null || map_x =="" || map_z =='' )
   {
     map_x ='(103.974609375,33.284619968887675)';
     map_z =4;  
   }
   
   map_x =map_x.replace('(','');
   map_x =map_x.replace(')','');
   var temp =map_x.split(',');
   map_x = temp[0];
   map_y = temp[1];  
   
   //if(map_x !=null && map_x != "" && map_z>0 )
   //{
   thispoint=new GLatLng(map_y,map_x,true);
   map.setCenter(thispoint,map_z);
   map.addOverlay(new GMarker(thispoint));   
   //}
   //else
   //{
   // map.setCenter(new GLatLng(37.86455455760559,112.55081176757812), 10);
   // alert(map_y);
   //}
   
  }catch(e){
   //alert(map_z);
   map.setCenter(new GLatLng(37.86455455760559,112.55081176757812), 10);//设置中心点
  }
  //标记事件
  
       GEvent.addListener(map,"click", function(overlay,point) {
   map.clearOverlays();//清除原有的标记
   map.addOverlay(new GMarker(point));
   save(point,map.getZoom());
  });
      
       
      }
    }

   
   
 
 


   

 

 
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn