Geolocation test
by shapeshifta
HTML
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div id="map"></div>
JavaScript
(function(doc, pos){
var test = function(position){
var mapcanvas = doc.getElementById('map');
mapcanvas.style.height = '400px';
mapcanvas.style.width = '560px';
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
myOptions = {
zoom: 15,
center: latlng,
mapTypeControl: false,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
},
map = new google.maps.Map(doc.getElementById("map"), myOptions),
marker = new google.maps.Marker({
position: latlng,
map: map,
title: "Du bist hier!"
});
};
if(pos){
pos.getCurrentPosition(test);
}else{
alert('Nicht unterstĂĽtzt');
}
})(document, navigator.geolocation);