Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function alertGeo() {
  2. navigator.geolocation.getCurrentPosition(onSuccess, onError);
  3. function onSuccess(position) {
  4. codeLatLng(position.coords.latitude,position.coords.longitude);
  5. }
  6. function onError(error) {
  7. alert(JSON.stringify(error));
  8. }
  9. }
  10.  
  11.  
  12. function codeLatLng(lat,lng) {
  13.  
  14. var latlng = new google.maps.LatLng(lat, lng);
  15. geocoder = new google.maps.Geocoder();
  16. geocoder.geocode({'latLng': latlng}, function(results, status) {
  17. if (status == google.maps.GeocoderStatus.OK) {
  18. if (results[1]) {
  19. alert("Address: " + results[1].formatted_address);
  20.  
  21. } else {
  22. alert('No results found');
  23. }
  24. } else {
  25. alert('Geocoder failed due to: ' + status);
  26. }
  27. });
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement