Advertisement
Guest User

Untitled

a guest
Sep 9th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. function localiza(){
  2. var lat;
  3. var lng;
  4. var latlng;
  5. var suc = function(p){
  6. console.log("geolocation success");
  7. if (p.coords.latitude != undefined)
  8. {
  9. lat = p.coords.latitude;
  10. lng = p.coords.longitude;
  11. console.log(lat);
  12. console.log(lng);
  13. latlng = new google.maps.LatLng(lat, lng);
  14. console.log(latlng);
  15. }
  16.  
  17. };
  18. var fail = function(){
  19. alert("geolocation failed");
  20. getLocation();
  21. };
  22.  
  23. intel.xdk.geolocation.getCurrentPosition(suc,fail);
  24.  
  25.  
  26. console.log(latlng);
  27. var geocoder= new google.maps.Geocoder();
  28.  
  29. geocoder.geocode({'latLng': latlng}, function(results, status) {
  30. if (status == google.maps.GeocoderStatus.OK) {
  31. if (results[1]) {
  32. map.setZoom(11);
  33. marker = new google.maps.Marker({
  34. position: latlng,
  35. map: map
  36. });
  37. infowindow.setContent(results[1].formatted_address);
  38. window.getElementById("endereco").value = results[1].formatted_address;
  39. console.log(results[1].formatted_address);
  40. infowindow.open(map, marker);
  41. } else {
  42. console.log("No results found");
  43. }
  44. } else {
  45. console.log("Geocoder failed due to: " + status);
  46. }
  47. });
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement