"use strict";
var __webpack_exports__={};
;
function cttmGeneratePopoverHTMLOutput(cttm_shortcode_options, cttm_options){
let popoverTarget;
let popoverOutput;
let popoverOptions;
if(cttm_shortcode_options.open_link_in_new_tab==='true'){
popoverTarget='_blank';
}else{
popoverTarget='_self';
}
let popoverStyles=cttm_options['popup_style'].split(',');
if(popoverStyles.indexOf('thumbnail')!=-1){
if(popoverStyles.indexOf('excerpt')!=-1){
popoverOptions={ className: 'detailed-popup' };
popoverOutput =
'<a class="tooltip-link" href="%s_url" target="' + popoverTarget + '">';
popoverOutput +='<div class="nothumbplaceholder"></div>';
popoverOutput +='<div class="title">%s_title</div>';
popoverOutput +='<div class="date">%s_date</div></a>';
popoverOutput +='%s_customfields';
popoverOutput +='<div class="excerpt">%s_excerpt</div>';
}else{
popoverOptions={ className: 'default-popup' };
popoverOutput='<div class="img-mask">';
popoverOutput +='<div class="nothumbplaceholder"></div>';
popoverOutput +=
'</div><a class="tooltip-link" href="%s_url" target="' +
popoverTarget +
'">';
popoverOutput +='<div class="popup-thumb-text-wrapper">';
popoverOutput +='<div class="title">%s_title</div>';
popoverOutput +='<div class="date">%s_date</div>';
popoverOutput +='%s_customfields';
popoverOutput +='</div></a>';
}}else{
popoverOptions={ className: 'textual-popup' };
popoverOutput =
'<a class="tooltip-link" href="%s_url" target="' + popoverTarget + '">';
popoverOutput +='<div class="title">%s_title</div>';
popoverOutput +='<div class="date">%s_date</div>';
popoverOutput +='%s_customfields';
popoverOutput +='<div class="excerpt">%s_excerpt</div></a>';
}
if(cttm_options['popup_css']){
popoverOptions={ className: 'custom-popup' };}
return [popoverOutput, popoverOptions];
}
;
function cttmPopulatePopoversHTMLOutput(
postdatas,
popoverOutput,
cttm_options
){
let postThumb=postdatas.thumb;
let posturl=postdatas.url;
let postTitle=postdatas.thetitle;
let postExcerpt=postdatas.excerpt;
let postDate=new Date(postdatas.date.replace(/ /g, 'T') + 'Z');
postDate=postDate.toLocaleDateString(undefined, {
year: 'numeric',
month: 'long',
day: 'numeric',
});
let postCustomFields=postdatas.customfields.fields;
let popoverStyles=cttm_options['popup_style'].split(',');
let postPopoverOutput=popoverOutput;
if(postThumb){
postPopoverOutput=postPopoverOutput.replace('<div class="nothumbplaceholder"></div>',
'<img src="' + postThumb + '" alt="">'
);
}
if(postExcerpt&&popoverStyles.indexOf('excerpt')!=-1){
postPopoverOutput=postPopoverOutput.replace('%s_excerpt', postExcerpt);
}else{
postPopoverOutput=postPopoverOutput.replace('<div class="excerpt">%s_excerpt</div>',
''
);
}
if(postTitle&&popoverStyles.indexOf('title')!=-1){
postPopoverOutput=postPopoverOutput.replace('%s_title', postTitle);
}else{
postPopoverOutput=postPopoverOutput.replace('<div class="title">%s_title</div>',
''
);
}
if(postDate&&popoverStyles.indexOf('date')!=-1){
postPopoverOutput=postPopoverOutput.replace('%s_date', postDate);
}else{
postPopoverOutput=postPopoverOutput.replace('<div class="date">%s_date</div>',
''
);
}
if(postCustomFields){
postPopoverOutput=postPopoverOutput.replace('%s_customfields', postCustomFields);
}else{
postPopoverOutput=postPopoverOutput.replace('%s_customfields',
''
);
}
postPopoverOutput=postPopoverOutput.replace('%s_url', posturl);
return postPopoverOutput;
}
;
function initTravelersMap(){
let json_cttm_options=cttm_options_params.cttm_options;
let cttm_shortcode_vars_arr=new Array();
let cttm_varname_pattern=/^cttm_shortcode_/;
for (let cttm_varName in window){
if(cttm_varname_pattern.test(cttm_varName)){
cttm_shortcode_vars_arr.push(window[cttm_varName]);
}}
let mapindex=0;
if(typeof cttm_map==='undefined'){
window.cttm_map=new Array();
window.cttm_markers=new Array();
}else{
for (let i=cttm_map.length - 1; i >=0; i--){
cttm_map[i].remove();
cttm_map.splice(i, 1);
}
for (let i=cttm_markers.length - 1; i >=0; i--){
cttm_markers[i].remove();
cttm_markers.splice(i, 1);
}}
cttm_shortcode_vars_arr.forEach(cttmMapLoop);
function cttmMapLoop(cttm_shortcode_vars){
if(cttm_shortcode_vars.cttm_metas=='0'){
return;
}
let json_cttm_shortcode=cttm_shortcode_vars.cttm_shortcode_options;
json_cttm_options=json_cttm_options.replace(/&quot;/g, '\\"');
json_cttm_shortcode=json_cttm_shortcode.replace(/&quot;/g, '\\"');
let cttm_options=JSON.parse(json_cttm_options);
var cttm_shortcode_options=JSON.parse(json_cttm_shortcode);
let cttm_map_options=new Object();
cttm_map_options.maxBounds=[
[-90, -Infinity],
[90, Infinity],
];
if(cttm_options['onefinger']){
cttm_map_options.dragging = !L.Browser.mobile;
cttm_map_options.tap = !L.Browser.mobile;
}
if(cttm_shortcode_options.maxzoom!=''){
cttm_map_options.maxZoom=cttm_shortcode_options.maxzoom;
}
if(cttm_shortcode_options.minzoom!=''){
cttm_map_options.minZoom=cttm_shortcode_options.minzoom;
}
if(cttm_shortcode_options.init_maxzoom){
var init_maxzoom=parseInt(cttm_shortcode_options.init_maxzoom);
}else{
var init_maxzoom=16;
}
if(cttm_shortcode_options.max_cluster_radius){
var max_cluster_radius=parseInt(
cttm_shortcode_options.max_cluster_radius
);
}else{
var max_cluster_radius=45;
}
let containerid=cttm_shortcode_options.id;
let container=document.getElementById('travelersmap-container-' + containerid
);
if(!container){
console.warn("Travelers' Map container with id: " + containerid + ' was not found.'
);
return;
}
let tileurl, subdomains, attribution;
if(cttm_shortcode_options.tileurl!==''){
tileurl=cttm_shortcode_options.tileurl;
}else{
tileurl=cttm_options['tileurl'];
}
if(cttm_shortcode_options.subdomains!==''){
subdomains=cttm_shortcode_options.subdomains;
}else{
subdomains=cttm_options['subdomains'];
}
if(cttm_shortcode_options.attribution!==''){
attribution=cttm_shortcode_options.attribution;
}else{
attribution=cttm_options['attribution'];
}
cttm_map.push(L.map(container, cttm_map_options));
cttm_markers.push(new Array());
L.tileLayer(tileurl, {
subdomains: subdomains,
attribution: attribution,
}).addTo(cttm_map[mapindex]);
cttm_map[mapindex].scrollWheelZoom.disable();
cttm_map[mapindex].on('focus', function (e){
this.scrollWheelZoom.enable();
});
L.Icon.Default.prototype.options.iconSize=[32, 45];
L.Icon.Default.prototype.options.iconAnchor=[16, 45];
L.Icon.Default.prototype.options.popupAnchor=[0, -42];
L.Icon.Default.prototype.options.shadowSize=[0, 0];
let markersGroup;
if(cttm_shortcode_options.disable_clustering==='true'){
markersGroup=L.featureGroup();
}else{
markersGroup=L.markerClusterGroup({
showCoverageOnHover: false,
maxClusterRadius: max_cluster_radius,
spiderLegPolylineOptions: {
weight: 3,
color: 'rgb(110, 204, 57)',
opacity: 0.6,
lineCap: 'round',
},
spiderfyDistanceMultiplier: 2.5,
});
}
let [popoverOutput, popoverOptions]=cttmGeneratePopoverHTMLOutput(
cttm_shortcode_options,
cttm_options
);
let json_cttm_metas=cttm_shortcode_vars.cttm_metas;
if(json_cttm_metas!=0){
json_cttm_metas=json_cttm_metas.replace(/&quot;/g, '\\"');
const cttm_metas=JSON.parse(json_cttm_metas);
for (let i=0; i < cttm_metas.length; i++){
if(cttm_metas[i].markerdatas){
let markerdatas=JSON.parse(cttm_metas[i].markerdatas);
let markerlatitude=markerdatas.latitude;
let markerlongitude=markerdatas.longitude;
let markerURL=markerdatas.markerdata[0];
let markerwidth=markerdatas.markerdata[1];
let markerheight=markerdatas.markerdata[2];
let postdatas=Object.assign({}, cttm_metas[i].postdatas);
if(markerdatas.customtitle){
postdatas.thetitle=markerdatas.customtitle;
}
if(markerdatas.customexcerpt){
postdatas.excerpt=markerdatas.customexcerpt;
}
if(markerdatas.customthumbnail){
postdatas.thumb=markerdatas.customthumbnail;
}
if(markerdatas.customanchor){
if(markerdatas.customanchor.charAt(0)=='#'){
postdatas.url +=markerdatas.customanchor;
}else{
postdatas.url +='#' + markerdatas.customanchor;
}}
if(markerURL!='d'){
let myIcon=L.icon({
iconUrl: markerURL,
iconSize: [markerwidth, markerheight],
iconAnchor: [markerwidth / 2, markerheight],
popupAnchor: [0, -markerheight + 3],
});
var marker=L.marker([markerlatitude, markerlongitude], {
icon: myIcon,
});
}else{
var marker=L.marker([markerlatitude, markerlongitude]);
}
marker.additionalData={
postid: postdatas.postID,
title: postdatas.thetitle,
multipleMarkersIndex: 0,
customFields: postdatas.customfields.fields
};
cttm_markers[mapindex].push(marker);
let postPopoverOutput=cttmPopulatePopoversHTMLOutput(
postdatas,
popoverOutput,
cttm_options
);
if(cttm_shortcode_options.this_post=='true' &&
!markerdatas.multiplemarkers
){
markersGroup.addLayer(marker);
}else{
markersGroup.addLayer(marker.bindPopup(postPopoverOutput, popoverOptions)
);
}
if(markerdatas.multiplemarkers &&
(cttm_options['only_main_marker']===0 ||
cttm_shortcode_options.this_post==='true')
){
for (let index=1; index < markerdatas.multiplemarkers; index++){
let postdatas=Object.assign({}, cttm_metas[i].postdatas);
let markerdatasMultiple =
markerdatas['additional_marker_' + index];
let markerlatitude=markerdatasMultiple.latitude;
let markerlongitude=markerdatasMultiple.longitude;
let markerURL=markerdatasMultiple.markerdata[0];
let markerwidth=markerdatasMultiple.markerdata[1];
let markerheight=markerdatasMultiple.markerdata[2];
if(markerdatasMultiple.customtitle){
postdatas.thetitle=markerdatasMultiple.customtitle;
}
if(markerdatasMultiple.customexcerpt){
postdatas.excerpt=markerdatasMultiple.customexcerpt;
}
if(markerdatasMultiple.customthumbnail){
postdatas.thumb=markerdatasMultiple.customthumbnail;
}
if(markerdatasMultiple.customanchor){
if(markerdatasMultiple.customanchor.charAt(0)=='#'){
postdatas.url +=markerdatasMultiple.customanchor;
}else{
postdatas.url +='#' + markerdatasMultiple.customanchor;
}}
if(markerURL!='d'){
let myIcon=L.icon({
iconUrl: markerURL,
iconSize: [markerwidth, markerheight],
iconAnchor: [markerwidth / 2, markerheight],
popupAnchor: [0, -markerheight + 3],
});
var marker=L.marker([markerlatitude, markerlongitude], {
icon: myIcon,
});
}else{
var marker=L.marker([markerlatitude, markerlongitude]);
}
marker.additionalData={
postid: postdatas.postID,
title: postdatas.thetitle,
multipleMarkersIndex: index,
};
cttm_markers[mapindex].push(marker);
let postPopoverOutput=cttmPopulatePopoversHTMLOutput(
postdatas,
popoverOutput,
cttm_options
);
if(cttm_shortcode_options.this_post=='true' &&
!markerdatas.multiplemarkers
){
markersGroup.addLayer(marker);
}else{
markersGroup.addLayer(marker.bindPopup(postPopoverOutput, popoverOptions)
);
}}
}}
}
if(cttm_options['search_field']==1){
cttm_map[mapindex].addControl(new L.Control.Search({
url: 'https://nominatim.openstreetmap.org/search?format=json&q={s}',
jsonpParam: 'json_callback',
propertyName: 'display_name',
propertyLoc: ['lat', 'lon'],
autoCollapse: false,
collapsed: false,
autoType: true,
minLength: 2,
zoom: 13,
firstTipSubmit: true,
hideMarkerOnCollapse: true,
})
);
document.querySelector('#searchtext9').addEventListener('focus',
function (){
cttm_map[mapindex].scrollWheelZoom.enable();
},
true
);
}
if(cttm_options['fullscreen_button']==1){
cttm_map[mapindex].addControl(new L.Control.Fullscreen({
position: 'topright',
})
);
}
cttm_map[mapindex].addLayer(markersGroup);
if(cttm_shortcode_options.centered_on_this=='true'){
let centered_on_marker=JSON.parse(cttm_metas[0].markerdatas);
let centerlatitude=centered_on_marker.latitude;
let centerlongitude=centered_on_marker.longitude;
cttm_map[mapindex].setView([centerlatitude, centerlongitude],
init_maxzoom
);
}else{
cttm_map[mapindex].fitBounds(markersGroup.getBounds(), {
padding: [60, 60],
maxZoom: init_maxzoom,
});
}}
const mapindexcopy=mapindex;
setTimeout(()=> {
cttm_map[mapindexcopy].invalidateSize();
}, 1000);
mapindex++;
}
let event_cttm=document.createEvent('Event');
event_cttm.initEvent('cttm_map_loaded', true, true);
document.dispatchEvent(event_cttm);
}
;
document.addEventListener('DOMContentLoaded', function (){
if(document.getElementsByClassName('travelersmap-container')){
initTravelersMap();
}});