I am making a web site targeted at mobile phones and would like to get the user's current GPS latitude/longitude when they visit my default page so I can show them results in their area. Is this possible using ASP.NET?
See Also
Get position data from mobile browser
Your browser uses different types and sources of information to identify your location. These include your IP address, geolocation via HTML5 in your browser, and your PC's language and time settings.
How Chrome shares your location. If you let Chrome share your location with a site, Chrome sends information to Google Location Services to get an estimate of where you are. Chrome can then share that info with the site that wants your location.
In order to get the current location of the user, we are going to use the getCurrentPosition() method which is available in the Navigator geolocation property. The getCurrentPosition() method is used for getting the current location of the user. Syntax: navigator.
Yes, you can do it with JavaScript and submit results back to server:
function onPositionUpdate(position)
{
var lat = position.coords.latitude;
var lng = position.coords.longitude;
alert("Current position: " + lat + " " + lng);
}
if(navigator.geolocation)
navigator.geolocation.getCurrentPosition(onPositionUpdate);
else
alert("navigator.geolocation is not available");
There are services that will give you a location based on IP address. It won't be as precise as the GPS data but without having an application installed on the phone it may be as close as you are going to get.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With