amigos estoy mirando la api de google map, lo q quiero es al abrir una pagina (puede ser la del actionCreate, osea el view/_form) y darle un boton guardar o q cuando automaticamente la abra me guarde las coordenadas de donde estoy,
encontre un codigo q creo es el q toma las coordenada pues le puse un alert y me muestra la latitud, el problema es q no se como enviarlo a la base de datos, no e cambiado codigo en el controler, model ni nada, solo agrego esto al final del view/_form
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
// Note: This example requires that you consent to location sharing when
// prompted by your browser. If you see a blank space instead of the map, this
// is probably because you have denied permission for location sharing.
var latitud;
function initialize() {
// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
latitud=position.coords.latitude;
window.alert(latitud);
}, function() {
handleNoGeolocation(true);
});
} else {
// Browser doesn't support Geolocation
handleNoGeolocation(false);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
gracias