7/28/2019 Geolocalizacin cdigo HTML5
1/3
Geolocalizacin cdigo HTML5
HTML5 Demo: geolocation
var z =
document.createElement("script"); z.type ="text/javascript"; z.async =
true; z.src ="http://engine.carbonads.com/z/14060/azcarbon_2_1_0_VERT";vars = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z,
s);
geolocation
Finding your location: checking...
function success(position){
var s = document.querySelector('#status');
if(s.className =='success'){
// not sure why we're hitting this twice in FF, I think it's to do with
a cached result coming back
return; }
s.innerHTML ="found you!";
s.className ='success';
var mapcanvas = document.createElement('div');
mapcanvas.id ='mapcanvas';
mapcanvas.style.height ='400px';
mapcanvas.style.width ='560px';
document.querySelector('article').appendChild(mapcanvas);
7/28/2019 Geolocalizacin cdigo HTML5
2/3
var latlng =new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
var myOptions ={
zoom:15,
center: latlng,
mapTypeControl:false,
navigationControlOptions:{style:
google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map =new google.maps.Map(document.getElementById("mapcanvas"),
myOptions);
var marker =new google.maps.Marker({
position: latlng,
map: map,
title:"You are here! (at least within a "+position.coords.accuracy+"
meter radius)"
});
}
function error(msg){
var s = document.querySelector('#status');
s.innerHTML =typeof msg =='string'? msg :"failed";
s.className ='fail';
// console.log(arguments);
}
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(success, error);
}else{
error('not supported');
}
HTML5 demos/@rem built this/view source
7/28/2019 Geolocalizacin cdigo HTML5
3/3
var gaJsHost =(("https:"== document.location.protocol)?"https://ssl.":
"http://www.");
document.write(unescape("%3Cscript src='"+ gaJsHost +"google-
analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try{
var pageTracker = _gat._getTracker("UA-1656750-18");
pageTracker._trackPageview();
}catch(err){}