2012-04-12 15 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

注意するのに役立ちますdeprecated](https://developers.google.com/maps/documentation/javascript/v2/) – ManseUK

答えて

1

です。だから、Googleはaddress.Use両方にテキストボックスから値を渡すために、次のコードを理解することはできません。

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

この1が動作するfine.HopeがこのマップV2をグーグル[あなたが:-)

+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

あなたはaddressとaddress1に値を取得しているかどうかチェックします。 – Unknown

関連する問題