Standort-bestimmumg-html5.php


Quell Code


<!DOCTYPE html> 
<html lang="de"> 
<head> 
    <meta charset="utf-8"/> 
    <title>HTML5 Geolocation Beispiel mit Hilfe von Google Maps</title>
    
    <script src="https://maps.google.com/maps/api/js?sensor=true"></script>
</head>

<body>
    <div id="pos" style="width:550px; height:300px;">
        Deine Position wird ermittelt...
    </div>
    
    <script>
        function initialize(coords) {
            var latlng = new google.maps.LatLng(coords.latitude, coords.longitude);
            var myOptions = {
                zoom: 8,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("pos"), myOptions);
            
            var marker = new google.maps.Marker({
                position: latlng, 
                map: map, 
                title: "Hier bist du :)"
            }); 
        }
  
        navigator.geolocation.getCurrentPosition(function(position){ 
            initialize(position.coords);
        }, function(){
            document.getElementById('pos').innerHTML = 'Deine Position konnte leider nicht ermittelt werden';
        });
    </script>
</body>
</html>


Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0