Created
December 12, 2017 12:24
-
-
Save sidneydemoraes/396626e668600186439c95085f540144 to your computer and use it in GitHub Desktop.
Geolocalização com javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.geolocation.getCurrentPosition(function(position){ | |
var latitude = position.coords.latitude; | |
var longitude = position.coords.longitude; | |
var request = new XMLHttpRequest(); | |
request.responseType = 'json'; | |
request.onreadystatechange = function(){ | |
console.log(request.response.results[0].formatted_address); | |
} | |
request.open("GET","https://maps.googleapis.com/maps/api/geocode/json?latlng="+latitude+", "+longitude+"&sensor=true",true); | |
request.send(null); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment