HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/zelfverkopen.komma.pro/resources/assets/js/site/mapsHandler.js
/* ==========================================================================
    Google Maps handler

    -- https://developers.google.com/maps/documentation/javascript/adding-a-google-map
 ========================================================================== */

var MapsHandler = {

    map: '',
    key: '',
    location: {lat: 51.2618222, lng: 5.5965538},
    styling: '',

    init: function () {
        // Get map by id
        MapsHandler.map = document.getElementById('map');

        // Check if a map is defined
        if (isset(MapsHandler.map)) {

            MapsHandler.key = MapsHandler.map.getAttribute('data-api-key');

            MapsHandler.location.lat = parseFloat(MapsHandler.map.getAttribute('data-google-lat'));
            MapsHandler.location.lng = parseFloat(MapsHandler.map.getAttribute('data-google-lng'));

            MapsHandler.setCustomStyling();

            // See if google variable exists
            if (typeof(google) == 'undefined' || typeof(google.maps) == 'undefined') {
                // Load external script
                $.getScript('https://maps.googleapis.com/maps/api/js?key=' + MapsHandler.key)
                    .done(function (script, textStatus) {
                        MapsHandler.drawMap();
                    });
            } else {
                MapsHandler.drawMap()
            }

        }

    },

    drawMap: function () {
        // Create a map
        var map = new google.maps.Map(MapsHandler.map, {
            zoom: 12,
            center: MapsHandler.location,
            disableDefaultUI: true,
            styles: MapsHandler.styling
        });
        // Add a marker
        var marker = new google.maps.Marker({
            position: MapsHandler.location,
            map: map
        });
    },

    setCustomStyling: function () {

        MapsHandler.styling =
            [
                {
                    "featureType": "landscape",
                    "stylers": [
                        {
                            "saturation": -100
                        },
                        {
                            "lightness": 60
                        }
                    ]
                },
                {
                    "featureType": "road.local",
                    "stylers": [
                        {
                            "saturation": -100
                        },
                        {
                            "lightness": 40
                        },
                        {
                            "visibility": "on"
                        }
                    ]
                },
                {
                    "featureType": "transit",
                    "stylers": [
                        {
                            "saturation": -100
                        },
                        {
                            "visibility": "simplified"
                        }
                    ]
                },
                {
                    "featureType": "administrative.province",
                    "stylers": [
                        {
                            "visibility": "off"
                        }
                    ]
                },
                {
                    "featureType": "water",
                    "stylers": [
                        {
                            "visibility": "on"
                        },
                        {
                            "lightness": 30
                        }
                    ]
                },
                {
                    "featureType": "road.highway",
                    "elementType": "geometry.fill",
                    "stylers": [
                        {
                            "color": "#ef8c25"
                        },
                        {
                            "lightness": 40
                        }
                    ]
                },
                {
                    "featureType": "road.highway",
                    "elementType": "geometry.stroke",
                    "stylers": [
                        {
                            "visibility": "off"
                        }
                    ]
                },
                {
                    "featureType": "poi.park",
                    "elementType": "geometry.fill",
                    "stylers": [
                        {
                            "color": "#b6c54c"
                        },
                        {
                            "lightness": 40
                        },
                        {
                            "saturation": -40
                        }
                    ]
                },
            ];
    }
};

MapsHandler.init();