如何从用户登录的位置获取街道地址的纬度和经度 [英] How Do I Get Latitude And Longitude Of A Street Address From Where User Has Logged In

查看:145
本文介绍了如何从用户登录的位置获取街道地址的纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中作为用户登录,将跟踪他登录的街道。我认为需要的是他的纬度和经度被追踪..有没有办法用他的IP地址追踪纬度和经度或如何做到这一点?没有gps在使用。我想使用googlemap ..任何帮助?提前谢谢...

i am developing an application wherein as user login, the street from where he has logged in is to be traced. what i thought is required is his latitude and longitude to be traced.. is there a way to trace the latitude and longitude using his ip address or how this could be done?? no gps is in use. i thought of using googlemap.. any help?? thanks in advance...

推荐答案

<form id="form1" runat="server">
   <div>
       <p id="demo">get location</p>
       <a href ="#" id="get_location">Get Location</a>
       <div id="map">
           <iframe id="google_map" width="700" height="350" src="https://maps.google.com.np?output=embed"></iframe>
       </div>
       <script>
           var x = document.getElementById("demo");

           var c = function (pos) {
               var latitude = pos.coords.latitude;

               var longitude = pos.coords.longitude;
              coords = latitude + ',' + longitude;
               var locality = pos.coords.locality;

                document.getElementById('google_map').setAttribute('src', 'https://maps.google.com.np/?q=' + coords + '&z=15&output=embed');
                x.innerHTML = "lat:" + latitude + "<br /> long: " + longitude + "<br /> locality:" + locality;
           }


               document.getElementById('get_location').onclick = function () {

                   if (navigator.geolocation) {
                       navigator.geolocation.getCurrentPosition(c);
                       return false;
                   } else {
                       alert("Geo Location is not supported on your current browser!");
                   }

       }
       </script>
   </div>
       <asp:HiddenField ID="HiddenField1" runat="server" />
       <asp:HiddenField ID="HiddenField2" runat="server" />
       <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1"  OnClientClick="ac()"  />
       <asp:TextBox ID="HiddenOffsetBox" runat="server" Visible="true" Text ="<%# latitude  %>" ></asp:TextBox>
   </form>


可以使用客户端IP获取经度和纬度



参考:

http:// www。 aspsnippets.com/Articles/Get-Latitude-and-Longitude-using-IP-Address-in-ASPNet.aspx [ ^ ]
It is possible to get the latitude and longitude using client IP

Refer:
http://www.aspsnippets.com/Articles/Get-Latitude-and-Longitude-using-IP-Address-in-ASPNet.aspx[^]


这篇关于如何从用户登录的位置获取街道地址的纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆