I am guessing this is more of a JavaScript question, but as I am trying to do this on Salesforce, I thought I will ask first here.
I have code that is supposed to give out location to the console, I remember it actually working before, but was away from the project for a while and can't fathom whats wrong with it.
Here's very simple code:
<apex:page >
<script>
var lat, lon;
navigator.geolocation.getCurrentPosition(function(position){
lat = position.coords.latitude;
lon = position.coords.longitude;
console.log("Longitude: "+lon+" Latitude:"+lat);
}
);
</script>
<h3><a href="#" onclick="navigator.geolocation.getCurrentPosition();">Get location</a></h3><br/>
</apex:page>
When I click on the href, I get error in console:
TypeMismatchError: DOM Exception 17: The type of an object was incompatible with the expected type of the parameter associated to the object.