I used navigator.geolocation.getCurrentPosition()
for geo location and i got lat long. But when i try to access Brazil country lat long using this method can't give me lat long.
Suggest me how to get lat long values in Brazil country.
Code:
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</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>