Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...
Posted
Comments
Akinmade Bond 26-Mar-14 2:56am    
I sure hope in your privacy terms, you're telling the user you're getting that information as that could lead to some serious privacy issues.

I don't think there is a way you can get the exact geographical location of a user based on his IP address. You can get an approximate location but getting the exact location is rare.
Codes DeCodes 26-Mar-14 6:20am    
no problem if i get approximate location..
Bernhard Hiller 26-Mar-14 3:23am    
Looks like the title and the content of your question are inconsistent.
From the title I'd conclude that the street address is known, and you are now interested in the geographic coordinates. But the content of the question shows that you do not know either.
So: what do you know, where do you want to get?
Codes DeCodes 26-Mar-14 6:05am    
well, what i wanted is a code to get latitude and longitude of the place from where user has logged in. from the latitude and longitude received, his street address is to be traced.. Do you know how it is done???

XML
<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>
 
Share this answer
 
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[^]
 
Share this answer
 
Comments
Codes DeCodes 26-Mar-14 2:23am    
jas, thanks for the link... this link takes ip of isp and returns city but not street address within city... is there a way to return street address as well. i doubt???
Tom Marvolo Riddle 26-Mar-14 3:12am    
Hi Agustus Jackson ,sorry for the late reply.

you can get street details using Geocoding API.Use reverse Geocoding process to get street address from lat & long.

To get more info:
https://developers.google.com/maps/documentation/geocoding/[^]
Google Maps in HTML, ASP.NET, PHP, JSP etc. with ease[^]
Codes DeCodes 26-Mar-14 6:18am    
thanks a lot for link jas.. by the link, i can get street address based on latitude and longitude... do you know how can i get latitude and longitude of a place from where user has logged??? i had done tonns of research but was not able to get exact result.. all pointed to the latitude and longitude of ISP .. not the computer from where user has logged in...
Tom Marvolo Riddle 26-Mar-14 6:21am    
Buddy i'm not sure but i hope this Link[^] will help you to get out of this
Codes DeCodes 30-Mar-14 6:38am    
thanks for link.. i got an error unable to connect to remote server on solution 5 code line 3.. where as the page is opened when i pasted the address in browser and opened it... do you have any idea about it???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900