javascript - 如何从 Asp Label.Text 加载航点坐标
问题描述
我在其中硬核值的第一个代码:
<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="TextBox1" runat="server"></asp:TextBox>
<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 [2]:https ://i.stack.imgur.com/7MzyC.png
解决方案
推荐阅读
- reactjs - 为什么这个点符号在 axios 和表达中会产生不同的输出
- html - flex 图像行在没有包装器的情况下收缩
- python - (Python,Keras)为什么我的预测值不接近真实值?
- python - TypeError:无法将 int 隐式转换为 str
- php - PHP中的嵌套三元运算符如何工作?
- c++ - 如何实施 Eigen 的建议以禁用并行化/多线程 - 预处理器令牌的位置和数量?
- laravel - 如何在 laravel 中安装 EditorMD
- python - 为什么 SQLAlchemy 不会提交更改?
- graph-theory - 如何删除 Graphviz 图形文件周围的边框?
- rxjs - 根据一些可观察值过滤 Angular 8 中的多个下拉值