good morning I greet you.
What happens is that I want to obtain the coordinates of google maps, by clicking on a button and that the information appears in an input type text file.
This is my code:
function getLocation(){ if(navigator.geolocation){ navigator.geolocation.getCurrentPosition(showPosition); }else{ document.getElementById("coord").innerHTML = "Ohhh! Lo Lamentamos." } } function showPosition(posicion){ document.getElementById("coord").innerHTML=""+ posicion.coords.latitude + posicion.coords.longitude; }
<script src="https://code.jquery.com/jquery-1.11.0.js" integrity="sha256-zgND4db0iXaO7v4CLBIYHGoIIudWI5hRMQrPB20j0Qw=" crossorigin="anonymous"></script>
<button onclick="getLocation()" class="localizar" title="Localizar"><img src="../imagenes/localizacion.png" alt="Icono localización" width="90%"></button>
<input type="text" class="form-control" name="lug_den" id="coord" placeholder="¿DONDÉ?" autocomplete="off" required maxlength="61">
I appreciate the help you can give me, I have been looking at other posts and forums and I have not found the solution. Thanks.