MediaWiki:Common.js: Difference between revisions

From Imperial Minerals Wiki
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: <script> function initMap() { var element = document.getElementById('map'); var coordinates = element.getAttribute('data-src').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...")
 
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
<script>
// Your other JavaScript code here
    function initMap() {
        var element = document.getElementById('map');
        var coordinates = element.getAttribute('data-src').split(',').map(function(coord) {
            return parseFloat(coord.trim());
        });


        var mapOptions = {
function initMap() {
            center: { lat: coordinates[0], lng: coordinates[1] },
    var element = document.getElementById('map');
            zoom: 15
    var coordinates = element.getAttribute('data-src').split(',').map(function(coord) {
        };
        return parseFloat(coord.trim());
        var map = new google.maps.Map(element, mapOptions);
    });


        var marker = new google.maps.Marker({
    var mapOptions = {
            position: { lat: coordinates[0], lng: coordinates[1] },
        center: { lat: coordinates[0], lng: coordinates[1] },
            map: map,
        zoom: 15
            title: 'Marker Title'
    };
        });
     var map = new google.maps.Map(element, mapOptions);
     }
</script>


<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIrgq5dZQ8haJIfKHbGco90OpDwYLiXwA&callback=initMap" async defer></script>
    var marker = new google.maps.Marker({
        position: { lat: coordinates[0], lng: coordinates[1] },
        map: map,
        title: 'Marker Title'
    });
}
 
// Include the Google Maps JavaScript API script with your API key
var script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBIrgq5dZQ8haJIfKHbGco90OpDwYLiXwA&callback=initMap';
script.async = true;
script.defer = true;
document.head.appendChild(script);

Revision as of 19:49, 19 February 2024

/* Any JavaScript here will be loaded for all users on every page load. */
// Your other JavaScript code here

function initMap() {
    var element = document.getElementById('map');
    var coordinates = element.getAttribute('data-src').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(element, mapOptions);

    var marker = new google.maps.Marker({
        position: { lat: coordinates[0], lng: coordinates[1] },
        map: map,
        title: 'Marker Title'
    });
}

// Include the Google Maps JavaScript API script with your API key
var script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBIrgq5dZQ8haJIfKHbGco90OpDwYLiXwA&callback=initMap';
script.async = true;
script.defer = true;
document.head.appendChild(script);