03_Map_Api.html
Dosyayı İndir
<!DOCTYPE html>
<html>
<body>
<div id="map" style="width:500px;height:500px"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -41.000, lng: 28.000},
zoom: 16
});
var infoWindow = new google.maps.InfoWindow({map: map});
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('Siz buradasınız');
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Yerkonumu hizmeti başarısız.' :
'Tarayıcı yer konumunu desteklemiyor');
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAaw4vFD9Xl2Y3YnMQmZfCfJAAzLl_3aWc&callback=initMap">
</script>
</body>
</html>
Dosyayı İndir