Template:Map: Difference between revisions
No edit summary  | 
				No edit summary  | 
				||
| Line 3: | Line 3: | ||
<script>  | <script>  | ||
     function initMap() {  |      function initMap() {  | ||
         var   |          var coordinates = '{{{GPS}}}';  | ||
         coordinates = coordinates.split(',').map(function(coord) {  | |||
            return parseFloat(coord.trim());  | |||
        });  | |||
         var mapOptions = {  |          var mapOptions = {  | ||
             center: coordinates,  |              center: { lat: coordinates[0], lng: coordinates[1] },  | ||
             zoom: 15  |              zoom: 15  | ||
         };  |          };  | ||
| Line 14: | Line 15: | ||
         var marker = new google.maps.Marker({  |          var marker = new google.maps.Marker({  | ||
             position: coordinates,  |              position: { lat: coordinates[0], lng: coordinates[1] },  | ||
             map: map,  |              map: map,  | ||
             title: 'Marker Title'  |              title: 'Marker Title'  | ||
| Line 20: | Line 21: | ||
     }  |      }  | ||
</script>  | </script>  | ||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIrgq5dZQ8haJIfKHbGco90OpDwYLiXwA&callback=initMap" async defer></script>  | <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIrgq5dZQ8haJIfKHbGco90OpDwYLiXwA&callback=initMap" async defer></script>  | ||
</nowiki>  | </nowiki>  | ||
Revision as of 18:57, 19 February 2024
<script> function initMap() { var coordinates = '{{{GPS}}}'; coordinates = coordinates.split(',').map(function(coord) { return parseFloat(coord.trim()); }); var mapOptions = { center: { lat: coordinates[0], lng: coordinates[1] }, zoom: 15 }; var map = new google.maps.Map(document.getElementById('map'), mapOptions); var marker = new google.maps.Marker({ position: { lat: coordinates[0], lng: coordinates[1] }, map: map, title: 'Marker Title' }); } </script> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIrgq5dZQ8haJIfKHbGco90OpDwYLiXwA&callback=initMap" async defer></script>