hi all
I have this code to Show (Display) Current GPS coordinates in TextBox on Button Click in JavaScript
It works from my laptop but it does not work from the phone
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_Key"></script>
<script type="text/javascript">
function ViewCoOrdinate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (p) {
var lat = p.coords.latitude;
var lng = p.coords.longitude;
document.getElementById("txtLat").value = lat;
document.getElementById("txtLon").value = lng;
});
} else {
alert('Geo Location feature is not supported in this browser.');
}
return false;
}
</script>
<input type="text" id="txtLat" />
<input type="text" id="txtLon" />
<input type="button" id="btnView" value="View" onclintclick="return ViewCoOrdinate()" />