+ 2
Hey can someone tell me the mistake i am doingin writing javascript of the HTML geolocation API
code isinserted below https://code.sololearn.com/WpJaLvJP7Agh/?ref=app
3 Answers
+ 2
onload= function(){
var c = function(pos){
var lat = pos.coords.latitude,
long = pos.coords.longitude,
coords = lat + ', ' + long
document.getElementById('google_map').setAttribute('src', 'https://maps.google.co.uk/?q=' + coords + '&z=60ouput=embed')
}
document.getElementById('get_location').onclick = function(){
navigator.geolocation.getcurrentposition(c);
return false;
}
}
+ 6
wrap your js code in
onload=function(){
}
and on the line 8 after function() there is a dot (.) rove that
+ 3
u didn't wrapped your whole js code in
onload =function (){
}