I am trying to get Location of user via javascript Geolocation API, and show a static image of the map using google maps API, but when I tried to run the script in a webpage, it didn't work,In chrome's javascript console, it says "Uncaught SyntaxError: Unexpected identifier". I am a bit confused because, there are no misplaced or extra semicolons. Here's the javascript code :
var button = document.querySelector("#button");
var output = document.querySelector("#output");
window.onload = init;
function init(){
button.addEventListener('click',getPosition,false);
}
function getPosition(evt){
var pos = navigator.geolocation.getCurrentPosition(showPosition,onError,{enableHighAccuracy:true,maximamAge:2000});
console.log(pos);
}
function showPosition(position){
output.innerHTML = "Your Current position is <br/> Latitude : "+position.coords.latitude+" , Longitude : "+position.coords.longitude;
var latlon = position.coords.latitude+","+position.coords.longitude;
var img_url = "http://maps.googleapis.com/maps/api/staticmap?center="+latlon+"&zoom=14&size=400x300&sensor=false";
document.getElementById("mapholder").innerHTML = "<img src='"+img_url+"' />";
}
function onError(){
output.innerHTML = "Something is wrong with your browser";
}
When I checked this code on JSLint it says "Unexpected character ';' ". I tried a lot but I am unble to find what's causing the problem. Please help me with that, Any type of suggestions are also welcome.