如何使用 lat/long 跟踪确切位置,使用 ASP.NET 跟踪用户的 IP 地址
How can I trace the exact location with lat/long and IP address of user using ASP.NET
当用户访问我的网站或在浏览器中打开我的网站时,我想存储用户的所有必要信息,如位置、城市、县、latitude/longitude 并包括 IP 地址作为嗯
我找到了一些答案并实施了它们。虽然他们给出了位置但不是用户的确切位置。
不要建议我使用freegeoip、dotnetcurry、iplocationtools等,都是没用的,也不给准确位置。
您所说的确切位置是什么意思?如果您期望厘米分辨率,您永远无法获得确切位置!因此,IP 地址提供的位置精度有限。也许您最好在支持 GPS 的设备中使用 GPS 以获得更准确的位置。
借助 google 地图地理定位,我在这里获取了纬度、经度,包括用户所在的确切位置。
对于 google 地图 API:“https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false”
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success);
} else {
alert("Geo Location is not supported on your current browser!");
}
function success(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
var myLatlng = new google.maps.LatLng(lat, long);
var geocoder, add, country;
geocoder = new google.maps.Geocoder();
geocoder.geocode({
'latLng': myLatlng
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
add = results[1].formatted_address;
country = results[9].formatted_address;
}
}
});
}
当用户访问我的网站或在浏览器中打开我的网站时,我想存储用户的所有必要信息,如位置、城市、县、latitude/longitude 并包括 IP 地址作为嗯
我找到了一些答案并实施了它们。虽然他们给出了位置但不是用户的确切位置。
不要建议我使用freegeoip、dotnetcurry、iplocationtools等,都是没用的,也不给准确位置。
您所说的确切位置是什么意思?如果您期望厘米分辨率,您永远无法获得确切位置!因此,IP 地址提供的位置精度有限。也许您最好在支持 GPS 的设备中使用 GPS 以获得更准确的位置。
借助 google 地图地理定位,我在这里获取了纬度、经度,包括用户所在的确切位置。 对于 google 地图 API:“https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false”
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success);
} else {
alert("Geo Location is not supported on your current browser!");
}
function success(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
var myLatlng = new google.maps.LatLng(lat, long);
var geocoder, add, country;
geocoder = new google.maps.Geocoder();
geocoder.geocode({
'latLng': myLatlng
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
add = results[1].formatted_address;
country = results[9].formatted_address;
}
}
});
}