/* * Copyright 2017 Google Inc. All rights reserved. * * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this * file except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF * ANY KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ // Style credit: https://snazzymaps.com/style/1/pale-dawn const mapStyle = [{ "featureType": "administrative", "elementType": "all", "stylers": [{ "visibility": "on" }, { "lightness": 33 } ] }, { "featureType": "landscape", "elementType": "all", "stylers": [{ "color": "#f2e5d4" }] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{ "color": "#c5dac6" }] }, { "featureType": "poi.park", "elementType": "labels", "stylers": [{ "visibility": "on" }, { "lightness": 20 } ] }, { "featureType": "road", "elementType": "all", "stylers": [{ "lightness": 20 }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#c5c6c6" }] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#e4d7c6" }] }, { "featureType": "road.local", "elementType": "geometry", "stylers": [{ "color": "#fbfaf7" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#21a157" }] }, { "featureType": "water", "elementType": "all", "stylers": [{ "visibility": "on" }, { "color": "#acbcc9" } ] }, ]; // Escapes HTML characters in a template literal string, to prevent XSS. // See https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content function sanitizeHTML(strings) { const entities = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; let result = strings[0]; for (let i = 1; i < arguments.length; i++) { result += String(arguments[i]).replace(/[&<>'"]/g, (char) => { return entities[char]; }); result += strings[i]; } return result; } function initMap() { // Create the map. const map = new google.maps.Map(document.getElementsByClassName('map')[0], { zoom: 7, center: { lat: 52.1326, lng: 5.2913 }, styles: [{ "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#21a157" }] }] }); map.data.loadGeoJson('/stores.php'); //Define the custom marker icons, using the store's "category". map.data.setStyle(feature => { return { icon: { url: `/screens/images/raw-svg/${feature.getProperty('category')}_cc.svg`, scaledSize: new google.maps.Size(32, 32) } }; }); const apiKey = 'AIzaSyDHwMU_0zaP0bCS48BXqt1O81sSi0YZs-g'; const infoWindow = new google.maps.InfoWindow(); infoWindow.setOptions({ pixelOffset: new google.maps.Size(0, -30) }); // Show the information for a store when its marker is clicked. map.data.addListener('click', event => { const category = event.feature.getProperty('category'); const name = event.feature.getProperty('name'); const description = event.feature.getProperty('description'); const hours = event.feature.getProperty('hours'); const phone = event.feature.getProperty('phone'); const klanturl = event.feature.getProperty('klanturl'); const klanturlaanbod = event.feature.getProperty('klanturlaanbod'); const klantlogo = event.feature.getProperty('klantlogo'); const position = event.feature.getGeometry().get(); const content = sanitizeHTML `

${name}

${description}



Telefoon: ${phone}
`; infoWindow.setContent(content); infoWindow.setPosition(position); infoWindow.open(map); function readLess() { if ($(".store-description").text().replace(/\s/g, '') != "" && !$(".store-description").hasClass("readless")) { var descDiv = $(".store-description"); var fullText = descDiv.text(); var shortText = fullText.slice("0", "50"); descDiv.html(shortText + "... Lees meer"); descDiv.css("display", "block"); $(".store-description").addClass("readless"); $("#readMore").on("touchstart click", function() { var textFinalform = fullText.replace(/(<|<)br\s*\/*(>|>)/g, ' '); descDiv.text(textFinalform); }); } } var checkExist = setInterval(function() { if ($('.store-description').length) { clearInterval(checkExist); readLess(); } }, 100); function telefoonSpatiering(telDiv) { //$(".telefoonnummer").each(function() { telDiv.each(function() { var tel = $(this).text(); var num = tel.replace(/[^0-9]/g, ''); var result = ""; Array.prototype.contains = function(obj) { var i = this.length; while (i--) { if (this[i] == obj) { return true; } } return false; } regio4 = ['0111', '0113', '0114', '0115', '0117', '0118', '0161', '0162', '0164', '0165', '0166', '0167', '0168', '0172', '0174', '0180', '0181', '0182', '0183', '0184', '0186', '0187', '0222', '0223', '0224', '0226', '0227', '0228', '0229', '0251', '0252', '0255', '0294', '0297', '0299', '0313', '0314', '0315', '0316', '0317', '0318', '0320', '0321', '0341', '0342', '0343', '0344', '0345', '0346', '0347', '0348', '0411', '0412', '0413', '0416', '0418', '0475', '0478', '0481', '0485', '0486', '0487', '0488', '0492', '0493', '0495', '0497', '0499', '0511', '0512', '0513', '0514', '0515', '0516', '0517', '0518', '0519', '0521', '0522', '0523', '0524', '0525', '0527', '0528', '0529', '0541', '0543', '0544', '0545', '0546', '0547', '0548', '0561', '0562', '0566', '0570', '0571', '0572', '0573', '0575', '0577', '0578', '0591', '0592', '0593', '0594', '0595', '0596', '0597', '0598', '0599']; if (num.length == "10") { if (num.slice(0, 2) == "06") { result = num.slice(0, 2) + " " + "-" + " " + num.slice(2, 4) + " " + num.slice(4, 6) + " " + num.slice(6, 8) + " " + num.slice(8, 10); } else { kengetal4 = (num.slice(0, 4)); if (regio4.contains(kengetal4)) { result = num.slice(0, 4) + " " + "-" + " " + num.slice(4, 7) + " " + num.slice(7, 10); } else { result = num.slice(0, 3) + " " + "-" + " " + num.slice(3, 6) + " " + num.slice(6, 8) + " " + num.slice(8, 10); } } } if (num.length == "11" && num.slice(0, 1) == "3") { result = "+" + num.slice(0, 2) + " " + num.slice(2, 4) + " " + num.slice(4, 7) + " " + num.slice(7, 9) + " " + num.slice(9, 11); } if ((num.length == "12" && num.slice(0, 1) == "3") || (num.length == "12" && num.slice(0, 1) == "4")) { result = "+" + num.slice(0, 2) + " " + num.slice(2, 5) + " " + num.slice(5, 8) + " " + num.slice(8, 10) + " " + num.slice(10, 12); } if ((num.length == "13" && num.slice(0, 4) == "0031") || (num.length == "13" && num.slice(0, 4) == "0032")) { result = "+" + num.slice(2, 4) + " " + num.slice(4, 7) + " " + num.slice(7, 9) + " " + num.slice(9, 11) + " " + num.slice(11, 13); } if (num.length == "14" && num.slice(0, 4) == "0049") { result = "+" + num.slice(2, 4) + " " + num.slice(4, 7) + " " + num.slice(7, 10) + " " + num.slice(10, 12) + " " + num.slice(12, 14); } if (result.length >= "10") { $(this).text(result); } }); } var checkExist3 = setInterval(function() { if ($('.sloepphone').length) { clearInterval(checkExist3); telefoonSpatiering($(".sloepphone")); } }, 100); }); }