google地圖 標記地圖代碼

來源:互聯網
上載者:User

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>

    <title>標記地圖</title>

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAc8Kc8QqRiIgpsK23Kp5gkBSH2hU1_Yr14uOHyNBnrSDSRu1cOxQAA7Zqsv6wfxH6g3z1AadUX7peSA" type="text/javascript教程" charset="utf-8"></script>

<!--改用自己的key-->

    <script type="text/javascript">
   function save(point,zoom){
    o = window.opener;
    
    if (point !=null ) {
      o.document.getElementById("layout_map").value='('+point.lng()+','+point.lat()+')';//經度
      //o.document.getElementById("map_y").value=point.lat();
      o.document.getElementById("layout_zoom").value=zoom;
      try {
       o.document.getElementById("emarked_img").src = "yun_qi_img/modify_note.gif" ; 
      }catch(e){}
     
     
    }
   
   }

    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());
  });
      
       
      }
    }

    </script>
    <style>
 <!--
 body{ margin:0px; padding:0px;}
 #save{ line-height:1.8em; text-align:center; width:700px;}
 -->
    </style>
  </head>
  <body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas" style="width: 900px; height: 550px"></div>
 <div id="save"><input value="儲存標記" onclick="javascript:window.close();" type="button"/></div>
  </body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.