2012-12-23 65 views
0

這個我的code.it顯示我的座標線。我想添加信息窗口這條線.. 當我點擊這條線它顯示任何我想要的信息。將信息窗口添加到行[谷歌地圖]

P.S.對不起,我的英語水平:(

flightPlanCoordinates = [ 
       new google.maps.LatLng(40.9921196514,47.8604733650), 
       new google.maps.LatLng(40.9922511293,47.8606186245), 
       new google.maps.LatLng(40.9926358563,47.8611079146), 
       new google.maps.LatLng(40.9929381070,47.8615028229), 
       new google.maps.LatLng(40.9931715315,47.8620863814), 
       new google.maps.LatLng(40.9933869955,47.8623375976), 
       new google.maps.LatLng(40.9936024589,47.8625888155), 
       new google.maps.LatLng(40.9942600516, 47.8634730879), 
       new google.maps.LatLng(40.9946698905, 47.8639284456), 
       new google.maps.LatLng(40.9951427577,47.8643998201), 
       new google.maps.LatLng(40.9956477404 ,47.8648835770), 
       new google.maps.LatLng(40.9959645185, 47.8651699964), 
       new google.maps.LatLng(40.9962812958, 47.8654564186), 
       new google.maps.LatLng(40.9965401588,47.8657069220), 
       new google.maps.LatLng(40.9970324883 ,47.8661781983), 
       new google.maps.LatLng(40.9972659548, 47.8663989707), 
       new google.maps.LatLng(40.9975468767, 47.8664409273), 
       new google.maps.LatLng(40.9978740427,47.8662277913), 
       new google.maps.LatLng(40.9982012084,47.8660150777), 
        new google.maps.LatLng(40.9985497469,47.8658461824), 
new google.maps.LatLng(40.9988327045,47.8660951747), 
    new google.maps.LatLng(40.9991045183,47.8664072712),    
    new google.maps.LatLng(40.9992585926,47.8665868156),     





     ]; 
     var flightPath = new google.maps.Polyline({ 
      path: flightPlanCoordinates, 
      strokeColor: '#FF0000', 
      strokeOpacity: 1.0, 
      strokeWeight: 2 
     }); 

     flightPath.setMap(map); 
+0

你的代碼沒有嘗試創建一個InfoWindow。 – Marcelo

回答

1

你需要一個"click" listener添加到打開的InfoWindow後顯示內容是這樣的(未測試)的折線:

var infowindow = new google.maps.InfoWindow(); 
    var contentString ="content for infowindow"; 
    google.maps.event.addListener(flightPlan,'click', function(event) { 
    infowindow.setContent(contentString); 
    infowindow.setPosition(event.latLng); 
    infowindow.open(map); 
    }); 

example

+0

感謝您的幫助。我這樣做))..所以謝謝 – brio