我在其中硬核值的第一个代码:
<script type="text/javascript">
function myfunction() {
var label3LatLng =
document.getElementById('<%=TextBox1.ClientID%>').value;
var label4LatLng =
document.getElementById('<%=TextBox2.ClientID%>').value;
L.Routing.control({
waypoints: [
L.latLng(21.5278654, 55.9196996),
L.latLng(23.5278654, 55.9196996)
],
routeWhileDragging: true,
geocoder: L.Control.Geocoder.nominatim()
}).addTo(map);
}
输出:[![硬核输出][1]][1]
带有文本框或标签的代码:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<input type="button" onclick="myfunction()" value="Click Me"
style="width:300px;">
</td>
</tr>
</table>
<div id="d1"></div>
<script type="text/javascript">
function myfunction() {
var label3LatLng =
document.getElementById('<%=TextBox1.ClientID%>').value;
var label4LatLng =
document.getElementById('<%=TextBox2.ClientID%>').value;
L.Routing.control({
waypoints: [
L.latLng(label3LatLng.trim()), // This assumes the label contains both latitude & longitude.
L.latLng(label4LatLng.trim()) // Note: call trim to remove any potential whitespace.
],
routeWhileDragging: true,
geocoder: L.Control.Geocoder.nominatim()
}).addTo(map);
}
[![使用文本框输入时的输出][2]][2]
即使我在文本框中输入值,警报消息也会显示该值,但路由机显示空值。
[1]:https://i.stack.imgur.com/x85v2.png https://i.stack.imgur.com/x85v2.png
[2]: https://i.stack.imgur.com/7MzyC.png https://i.stack.imgur.com/7MzyC.png
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)