2012-04-12 3 views
0

gdrirection.load()를 호출 할 때 문제가 발생했습니다. 작동하는 값을 지정했지만 텍스트 상자를 통해 전달하면 작동하지 않습니다. 여기 내 코드는 주소로 같은 주소로 TextBox1txtAddress을 전달하는google map api v2

var map; 
    var directionsPanel; 
    var directions; 
function initialize() { 

     if (GBrowserIsCompatible()) { 
      map = new GMap2(document.getElementById("map")); 
      map.setCenter(new GLatLng(24.7116667, 46.7241667), 12); 
      map.setUIToDefault(); 
      var txtAddress = document.getElementById('txtAddress').value; 
      var TextBox1 = document.getElementById('TextBox1').value; 
      directions = new GDirections(map, directionsPanel); 
      directions.load("from: 'TextBox1' to: 'txtAddress'");   
     } 
    } 
<body onload=initialize()> 

      <asp:TextBox ID="txtAddress" runat="server" Visible="true" /> 
      <input type="button" value="direction" onclick="initialize();" title="direction" /> 
      <asp:TextBox ID="TextBox1" runat="server" Visible="true"></asp:TextBox>` 

주셔서 감사합니다 코드에서

+0

참고 [지도 V2입니다 구글 :-) 당신을 도와 fine.Hope 작동합니다 : 그래서 구글은 address.Use 모두에게 텍스트 상자에서 값을 전달하려면 다음 코드를 이해 할 수 없습니다 deprecated] (https://developers.google.com/maps/documentation/javascript/v2/) – ManseUK

답변

1

입니다.

directions.load("from: "+TextBox1+" to: "+txtAddress+""); 

이 하나가이

+0

답장을 보내 주셔서 감사합니다. 코드를 약간 변경했지만 여전히 작동하지 않습니다. – user1328645

+0

다음은 코드입니다. 'var txtAddress = document.getElementById ("<% = txtAddress.ClientID %>"); var address = txtAddress.value; var TextBox1 = document.getElementById ("<% = TextBox1.ClientID %>"); var address1 = TextBox1.value; directions = new GDirections (map, directionsPanel); directions.load ("from :"+ TextBox1 + "to :"+ txtAddress + ""); ' – user1328645

+0

일단 주소 및 주소 1에 값을 가져 오는지 확인하십시오. – Unknown