how can I load the waypoint coordinates from Asp Label.Text

只谈情不闲聊 提交于 2020-12-26 13:42:40

问题


First code in which i hardcore the value:

<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);
    }

Output:[![Output with hardcore][1]][1]

Code with textbox or labels: <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);
    }

[![Output when entered with TextBox][2]][2]

Even if i enter the values in the Textbox Alert message shows the value but routing machine shows empty values. [1]: https://i.stack.imgur.com/x85v2.png [2]: https://i.stack.imgur.com/7MzyC.png

来源:https://stackoverflow.com/questions/65305764/how-can-i-load-the-waypoint-coordinates-from-asp-label-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!