Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="map">
- <script>
- function initMap()
- {
- var map = new google.maps.Map(document.getElementById('map'), {
- center: {lat: -34.397, lng: 150.644},
- zoom: 16
- });
- var infoWindow = new google.maps.InfoWindow({map: map});
- // Try HTML5 geolocation.
- if (navigator.geolocation)
- {
- navigator.geolocation.watchPosition(function(position)
- {
- var pos =
- {
- lat: position.coords.latitude,
- lng: position.coords.longitude
- };
- infoWindow.setPosition(pos);
- infoWindow.setContent('Tutaj jesteล');
- map.setCenter(pos);
- }, function()
- {
- handleLocationError(true, infoWindow, map.getCenter());
- });
- }
- else {
- // Browser doesn't support Geolocation
- handleLocationError(false, infoWindow, map.getCenter());
- }
- }
- function handleLocationError(browserHasGeolocation, infoWindow, pos) {
- infoWindow.setPosition(pos);
- infoWindow.setContent(browserHasGeolocation ?
- 'Error: The Geolocation service failed.' :
- 'Error: Your browser doesn\'t support geolocation.');
- }
- </script>
- <script async defer
- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDZg7lXCatX7_I9nqP5PcUgslu3QKnZXMA&callback=initMap">
- </script>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement