2011-03-31 65 views

回答

0

查看Google地圖文檔引用的多邊形數組示例。它展示瞭如何繪製多邊形,以及如何響應這些多邊形的點擊。

查看例如:

http://code.google.com/apis/maps/documentation/javascript/examples/polygon-arrays.html

要查看它後面的源代碼:

視圖-出處:http://code.google.com/apis/maps/documentation /javascript/examples/polygon-arrays.html

+1

這很酷,很容易理解。我可以整合KML文件來生成這些多邊形,然後添加類似的事件嗎? – 2011-03-31 19:39:44

0
function initialize() { 

    var mapOptions = { 
     zoom: 5, 
     center: new google.maps.LatLng(41.376259, 25.055542), 
     mapTypeId: google.maps.MapTypeId.TERRAIN 
    }; 

    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); 

    var Place = new google.maps.KmlLayer({ 
     url: 'path-to-kml.kml' 
    }); 

    Place.setMap(map); 

    google.maps.event.addListener(Place, 'click', function (event) { 
     window.location.href = 'http://example.com' 
    }); 

} 

google.maps.event.addDomListener(window, 'load', initialize); 
相關問題