admin管理员组文章数量:1357602
I already found functionality that can give a users country or state using his or her IP address. But what I actually need is the exact location.
Like you can see on this link, it is possible to get the very specific current location of a user.
How is this possible with ASP.NET C#, Javascript or jQuery?
I already found functionality that can give a users country or state using his or her IP address. But what I actually need is the exact location.
Like you can see on this link, it is possible to get the very specific current location of a user.
How is this possible with ASP.NET C#, Javascript or jQuery?
Share Improve this question edited Jun 12, 2012 at 9:09 Manse 38.1k11 gold badges86 silver badges111 bronze badges asked Jun 12, 2012 at 8:55 OzkanOzkan 4,1709 gold badges54 silver badges86 bronze badges 1- Check this stackoverflow./questions/1535619/… – V4Vendetta Commented Jun 12, 2012 at 8:59
2 Answers
Reset to default 5 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
}
you can find details here
Warning:This will popup a permission dialog in browsers that will look something like this (Safari):
You could use the Geolocation API in JavaScript ... to get the current position use this :
navigator.geolocation.getCurrentPosition(function(position) {
do_something(position.coords.latitude, position.coords.longitude);
});
do_something()
could be to update a map or just show the current longitude and latitude. Nice simple example here
Browser support (Source):
- Firefox 3.5+
- Chrome 5.0+
- Safari 5.0+
- Opera 10.60+
- Internet Explorer 9.0+
API Spec here
本文标签: cGet current location of a visitorStack Overflow
版权声明:本文标题:c# - Get current location of a visitor - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744059534a2583871.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论