MediaWiki:Common.js

From Imperial Minerals Wiki
Revision as of 19:11, 19 February 2024 by Woveadmin (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* 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(element, 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>