I'm trying to get location through java application via GPS and I found it not useful , most computers don't have GPS sensor , so I've tried to get it online , I had found a way by HTML code reading Latitude and Longitude (CODE below ) , now I need to attache this code into my java application !
so in steps
- I Need to convert this value of Latitude and Longitude into a place
- Save This result
- Get the result into my Java Application
also I want to ask if it's possible to do all of this things implicit without opening the browser(or open it in background).
I'll be so grateful for your help
HTML CODE>>
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">GET LOCATION</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>