Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function localiza(){
- var lat;
- var lng;
- var latlng;
- var suc = function(p){
- console.log("geolocation success");
- if (p.coords.latitude != undefined)
- {
- lat = p.coords.latitude;
- lng = p.coords.longitude;
- console.log(lat);
- console.log(lng);
- latlng = new google.maps.LatLng(lat, lng);
- console.log(latlng);
- }
- };
- var fail = function(){
- alert("geolocation failed");
- getLocation();
- };
- intel.xdk.geolocation.getCurrentPosition(suc,fail);
- console.log(latlng);
- var geocoder= new google.maps.Geocoder();
- geocoder.geocode({'latLng': latlng}, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- if (results[1]) {
- map.setZoom(11);
- marker = new google.maps.Marker({
- position: latlng,
- map: map
- });
- infowindow.setContent(results[1].formatted_address);
- window.getElementById("endereco").value = results[1].formatted_address;
- console.log(results[1].formatted_address);
- infowindow.open(map, marker);
- } else {
- console.log("No results found");
- }
- } else {
- console.log("Geocoder failed due to: " + status);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement