Skip to content

Instantly share code, notes, and snippets.

@sebasjm
Created September 7, 2012 16:58
Show Gist options
  • Select an option

  • Save sebasjm/3667766 to your computer and use it in GitHub Desktop.

Select an option

Save sebasjm/3667766 to your computer and use it in GitHub Desktop.
geoloc
<!-- GEO LOC -->
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true"></script>
<input id="ubicacion" type="text" value="" /> &nbsp; <a href="javascript:confirmar_ubicacion()"> confirmar ubicación </a>
<script>
// new google.maps.Geocoder().geocode({'address':'buenos aires'},function(r,s){$('#personal-data-location-input').html(pepe(r[0].formatted_address));})
function confirmar_ubicacion(){
var geocoder = new google.maps.Geocoder();
var ubicacion = $('#ubicacion').val();
if (!ubicacion || ubicacion == "") console.log( "Something went wrong");
geocoder.geocode(
{'address': ubicacion},
function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
ubicacion = results[0].formatted_address;
$('#ubicacion').val( ubicacion );
}
}
}
);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment