我在调用gdrirection.load()时遇到了问题,如果我指定了值,它就会起作用,但是如果我通过文本框传递它们,它就不会起作用。这是我的代码
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>`谢谢
发布于 2012-04-12 17:34:46
在您的代码中,将TextBox1作为from address传递,将txtAddress作为to address传递。因此,谷歌无法理解从文本框中传递值的两个address.Use代码:
directions.load("from: "+TextBox1+" to: "+txtAddress+"");这将工作fine.Hope这帮助你:-)
https://stackoverflow.com/questions/10120776
复制相似问题