zoukankan      html  css  js  c++  java
  • Google 地图 JavaScript API 示例: 标记拖动事件

    代码
    <!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> 
        
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
        
    <title>Google 地图 JavaScript API 示例: 标记拖动事件 </title> 
        
    <script src="http://ditu.google.cn/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=zh-CN" 
                type
    ="text/javascript"> </script> 
        
    <script type="text/javascript"> 
        
    function initialize() { 
          
    if (GBrowserIsCompatible()) { 
            
    var map = new GMap2(document.getElementById("map_canvas")); 
            
    var center = new GLatLng(39.917,116.397); 
            map.setCenter(center, 
    14); 
            
    var marker = new GMarker(center, {draggable: true}); 
            GEvent.addListener(marker, 
    "dragstart"function() { 
              map.closeInfoWindow(); 
            }); 
            GEvent.addListener(marker, 
    "dragend"function() { 
              
    //marker.openInfoWindowHtml("正在反弹..."); 
    var custPoint = marker.getPoint(); 
    alert(
    "经度"+custPoint.lng()+"  纬度"+custPoint.lat()) 
            }); 
            map.addOverlay(marker); 
          } 
        } 
        
    </script> 
      
    </head> 
      
    <body onload="initialize()" onunload="GUnload()"> 
        
    <div id="map_canvas" style=" 500px; height: 300px"> </div> 
      
    </body> 
    </html>
  • 相关阅读:
    SSH协议详解
    适用于Rick的奖惩体系
    LeetCode 4 Median of Two Sorted Array
    一丁点算法学习感悟
    algorithm ch7 QuickSort
    algorithm ch6 priority queque
    algorithm ch6 heapsort
    algorithm ch2 Merge_sort
    关于gsl库出现access violation 0X00000005问题的解决方法
    LeetCode 3 Longest Substring Without Repeating Characters
  • 原文地址:https://www.cnblogs.com/Fooo/p/1652009.html
Copyright © 2011-2022 走看看