C# 获取访问者的当前位置

C# 获取访问者的当前位置,c#,javascript,jquery,asp.net,.net,C#,Javascript,Jquery,Asp.net,.net,我已经找到了可以使用用户的IP地址为用户提供国家或州信息的功能。但我真正需要的是确切的位置 正如您在上所看到的,可以获取用户的非常特定的当前位置 使用ASP.NET C#、Javascript或jQuery如何实现这一点?您可以在Javascript中使用。。。要获取当前位置,请使用以下命令: navigator.geolocation.getCurrentPosition(function(position) { do_something(position.coords.latitude,

我已经找到了可以使用用户的IP地址为用户提供国家或州信息的功能。但我真正需要的是确切的位置

正如您在上所看到的,可以获取用户的非常特定的当前位置

使用ASP.NET C#、Javascript或jQuery如何实现这一点?

您可以在Javascript中使用。。。要获取当前位置,请使用以下命令:

navigator.geolocation.getCurrentPosition(function(position) {
  do_something(position.coords.latitude, position.coords.longitude);
});
do_something()
可以是更新地图,也可以只是显示当前的经度和纬度

浏览器支持():

  • 火狐3.5+
  • 铬5.0+
  • Safari 5.0+
  • 歌剧院10.60+
  • Internet Explorer 9.0+

警告:这将在浏览器中弹出一个类似以下内容的权限对话框(Safari):

检查一下,如果可以的话,我会投两次票,因为你没有把它称为HTML5!:-)你知道谷歌是如何在没有GPS或其他东西的情况下让用户知道准确的位置的吗?
  navigator.geolocation.getCurrentPosition(
      onSuccess,
      onError, {
        enableHighAccuracy: true,
        timeout: 20000,
        maximumAge: 120000
      });

function onSuccess(position) {
      //the following are available to use
  //position.coords.latitude
  //position.coords.longitude
 // position.coords.altitude
 // position.coords.accuracy
 // position.coords.altitudeAccuracy
 // position.coords.heading
 // position.coords.speed 


}