简体   繁体   English

通过HTML5地理位置API识别用户的地理位置

[英]Identifying geolocation of user by other than HTML5 Geolocation API

I am writing an web application in Jsp that requires to identify the geolocation of the user. 我正在用Jsp编写一个Web应用程序,该应用程序需要标识用户的地理位置。 I have tried the code of w3schools using HTML5 geolocation api. 我已经尝试过使用HTML5地理位置api的w3schools代码。 But it is not executing on Tomcat. 但是它不在Tomcat上执行。 I have posted that problem here but got no solution. 我已经在这里发布了该问题,但没有解决方案。 So I think it cannot be done. 所以我认为这是不可能的。

So now I am looking for alternative ways to do the same. 因此,现在我正在寻找替代方法。 I am asking is there any other way by which I can identify the current location of the user? 我问我还有其他方法可以识别用户的当前位置吗? Actually I am new to web technologies. 实际上,我是Web技术的新手。 So if anyone give any idea regarding this I will be really grateful. 因此,如果有人对此有任何想法,我将非常感激。 Thank you. 谢谢。

EDIT: Is it possible to use whois to identify the location of an user? 编辑:是否可以使用whois来识别用户的位置?

You can get Geo location in HTML5 Application use corodva JS http://docs.phonegap.com/en/2.5.0/cordova_geolocation_geolocation.md.html 您可以使用corodva JS http://docs.phonegap.com/en/2.5.0/cordova_geolocation_geolocation.md.html在HTML5应用程序中获取地理位置

var onSuccess = function(position) {
alert('Latitude: '          + position.coords.latitude          + '\n' +
      'Longitude: '         + position.coords.longitude         + '\n' +
      'Altitude: '          + position.coords.altitude          + '\n' +
      'Accuracy: '          + position.coords.accuracy          + '\n' +
      'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
      'Heading: '           + position.coords.heading           + '\n' +
      'Speed: '             + position.coords.speed             + '\n' +
      'Timestamp: '         + position.timestamp                + '\n');
};

// onError Callback receives a PositionError object

function onError(error) {
alert('code: '    + error.code    + '\n' +
      'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM