Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function alertGeo() {
- navigator.geolocation.getCurrentPosition(onSuccess, onError);
- function onSuccess(position) {
- codeLatLng(position.coords.latitude,position.coords.longitude);
- }
- function onError(error) {
- alert(JSON.stringify(error));
- }
- }
- function codeLatLng(lat,lng) {
- var latlng = new google.maps.LatLng(lat, lng);
- geocoder = new google.maps.Geocoder();
- geocoder.geocode({'latLng': latlng}, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- if (results[1]) {
- alert("Address: " + results[1].formatted_address);
- } else {
- alert('No results found');
- }
- } else {
- alert('Geocoder failed due to: ' + status);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement