What I am trying to do is find a user's location using html5 geolocation and store the latitude and longitude coordinates into an array for further use with google maps and sql statements. When I try putting them into the array and writing it to the window, nothing shows up or it says it is undefined. The code below is just a way to show me whether or not it is being put into the array. Thanks in advance!
<script>
var array = [];
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
array.push(lat, lon);
}
document.write(array);
</script>
getLocation()