简体   繁体   中英

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. I have tried the code of w3schools using HTML5 geolocation api. But it is not executing on 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. So if anyone give any idea regarding this I will be really grateful. Thank you.

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

You can get Geo location in HTML5 Application use corodva JS http://docs.phonegap.com/en/2.5.0/cordova_geolocation_geolocation.md.html

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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