function mapClickSim(m,i){new bootstrap.Modal(document.getElementById('contentMapModal_'+m)).show();function w(){if(window.contentMaps[m]!==undefined&&typeof toggleMapIconClick==="function"&&typeof resetMarkersAndCards==="function"){resetMarkersAndCards(m);setTimeout(()=>{toggleMapIconClick(m,i,true);},500);}else{setTimeout(w,100);}} w();} function handleActionClick(e){const target=e.target.closest('[data-action]');if(!target)return;const{action,actionArgs}=target.dataset;const fn={mapClickSim}[action];fn&&fn(...actionArgs.split(',').map(Number));} if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',()=>{document.querySelectorAll('[data-action]').forEach(b=>b.addEventListener('click',handleActionClick));});}else{document.querySelectorAll('[data-action]').forEach(b=>b.addEventListener('click',handleActionClick));}function genImgContent(p,m){p=JSON.parse(p);if(Array.isArray(p[0])){let d='carousel'+Math.random().toString(36).substr(2,9);b='';for(let i=0;i`;} let c=``;return c;}else{return genImg(p,m);}} function genImg(p,m){var c=m?'w-100 h-100 object-fit-cover':'img-fluid w-100';var a=p[0];var u=`https://cdn.lazytrips.com/photos/`+a.slice(0,2)+'/'+a.slice(2,4)+'/'+a;var r=``+p[1]+``;return r;} function getNewLngLat(m,o,f){var p=m.project(new mapboxgl.LngLat(o[0],o[1]));p.x+=f.x;p.y+=f.y;return m.unproject(p);} function onMapZoom(m){console.log('fired');if(contentMaps[m]){contentMaps[m].on('zoom',function(){Object.keys(markerData[m]).forEach(function(i){var p=markerData[m][i];if(!mDev()&&p.cardInstance){var o={x:p.c.card.oX,y:p.c.card.oY};var n=getNewLngLat(contentMaps[m],p.lonLat,o);p.cardInstance.setLngLat([n.lng,n.lat]);}});});}} async function fetchRoute(d,m,i,c){const p={routeId:d};const r=await fetch('/api/request-route',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(p)});if(r.ok){const j=await r.json();if(j.response&&j.response.route){const d=JSON.parse(j.response.route);markerData[m][i].c.route.json=d;updateMapWithRoute(m,i,d,c);}}} function updateMapWithRoute(m,i,r,c){const l='iconRoute_'+m+'_'+i;const g={type:'Feature',properties:{},geometry:{type:'LineString',coordinates:r}};if(contentMaps[m].getLayer(l)){contentMaps[m].setLayoutProperty(l,'visibility','visible');contentMaps[m].getSource(l).setData(g);}else{contentMaps[m].addLayer({id:l,type:'line',source:{type:'geojson',data:g},layout:{'line-join':'round','line-cap':'round'},paint:{'line-color':c,'line-width':5,'line-opacity':0.8}});}} function hideRouteLayer(m,i){const l='iconRoute_'+m+'_'+i;if(contentMaps[m].getLayer(l)){contentMaps[m].setLayoutProperty(l,'visibility','none');}} window.toggleMapIconClick=function(m,i,e=true){if(markerData[m][i].a){return;} for(const[key,icon]of Object.entries(markerData[m])){if(parseInt(key)===i){continue;} if(icon.popupInstance){icon.popupInstance.remove();delete icon.popupInstance;} if(icon.c?.route&&contentMaps[m].getLayer('iconRoute_'+m+'_'+key)){hideRouteLayer(m,key);} if(icon.marker){icon.marker.getElement().classList.remove('markerSpanSelect');} if(icon.cardInstance){icon.cardInstance.remove();delete icon.cardInstance;} if(icon.cardOverlay){var o=icon.cardOverlay;if(o&&o.parentNode){o.parentNode.removeChild(o);delete icon.cardOverlay;}} icon.a=false;} if(!markerData[m][i].a){markerData[m][i].marker.getElement().classList.add('markerSpanSelect');if(markerData[m][i].c?.popup){const t=markerData[m][i].c.popup.title;const p=markerData[m][i].c.popup.text;let popupHTML='
';if(t){popupHTML+='

'+t+'

';} if(p){popupHTML+='

'+p+'

';} popupHTML+='
';var popup=new mapboxgl.Popup({anchor:'bottom',closeButton:false,closeOnClick:false,className:'pointer'}).setLngLat(markerData[m][i].lonLat).setHTML(popupHTML).addTo(contentMaps[m]);markerData[m][i].popupInstance=popup;popup._content.addEventListener('click',function(){toggleMapIconClick(m,i);});markerData[m][i].marker.getElement().style.display='none';} if(markerData[m][i].c?.route){const layerId='iconRoute_'+m+'_'+i;if(contentMaps[m].getLayer(layerId)){contentMaps[m].setLayoutProperty(layerId,'visibility','visible');}else{fetchRoute(markerData[m][i].c.route.id,m,i,markerData[m][i].c.route.color);}} if(markerData[m][i].c?.card){var cardContent={n:markerData[m][i].c.card.title,d:markerData[m][i].c.card.d,t:markerData[m][i].c.card.t,p:markerData[m][i].c.card.p,};if(markerData[m][i].c.card.hasOwnProperty('link')){cardContent.l=markerData[m][i].c.card.link;} if(markerData[m][i].c.card.hasOwnProperty('linkText')){cardContent.s=markerData[m][i].c.card.linkText;} if(!mDev()){var cardContentHtml=createCardContentHtml(cardContent,false);var offsets={x:markerData[m][i].c.card.oX,y:markerData[m][i].c.card.oY};var newLngLat=getNewLngLat(contentMaps[m],markerData[m][i]['lonLat'],offsets);var cardPopup=new mapboxgl.Popup({anchor:'bottom',closeButton:false,closeOnClick:false,className:'mapPopupCard'}).setHTML(cardContentHtml).setLngLat([newLngLat.lng,newLngLat.lat]).addTo(contentMaps[m]);markerData[m][i].cardInstance=cardPopup;setTimeout(()=>{if(markerData[m][i].cardInstance&&markerData[m][i].cardInstance.isOpen()){markerData[m][i].c.card.height=markerData[m][i].cardInstance.getElement().offsetHeight;}},10);}else{var cardMobile=document.createElement('div');cardMobile.className='mapPopupCardMobile';cardMobile.innerHTML=createCardContentHtml(cardContent,true);var mapContainer=contentMaps[m].getContainer();mapContainer.appendChild(cardMobile);markerData[m][i].cardOverlay=cardMobile;}} markerData[m][i].a=true;if(e){updateMapBounds(m,i);}}else{resetMarkersAndCards(m);}} window.resetMarkersAndCards=function(m){Object.keys(markerData[m]).forEach((i)=>{if(markerData[m][i].marker){markerData[m][i].marker.getElement().classList.remove('markerSpanSelect');} if(markerData[m][i].popupInstance){markerData[m][i].popupInstance.remove();delete markerData[m][i].popupInstance;} if(markerData[m][i].c&&markerData[m][i].c.route){if(contentMaps[m].getLayer('iconRoute_'+m+'_'+i)){hideRouteLayer(m,i);}} if(markerData[m][i].c&&markerData[m][i].c.card){if(markerData[m][i].cardInstance){markerData[m][i].cardInstance.remove();delete markerData[m][i].cardInstance;}} if(markerData[m][i].cardOverlay){var o=markerData[m][i].cardOverlay;if(o&&o.parentNode){o.parentNode.removeChild(o);delete markerData[m][i].cardOverlay;}} markerData[m][i].marker.getElement().style.display='block';markerData[m][i].a=false;});} function formatTime(t){const h=Math.floor(t / 60);const m=t%60;return`⏱️ ${h > 0 ? h + " hour" + (h > 1 ? "s" : "") : ""}${h > 0 && m > 0 ? ", " : ""}${m > 0 ? m + " minute" + (m > 1 ? "s" : "") : ""}`;} function createCardContentHtml(c,m){cC='';if(m){cC=' d-flex flex-row';} let h='
';if(c.p){p=genImgContent(c.p,m);h+='
'+p+'
';} if(c.n||c.d||c.t||c.l){h+='
';if(c.n){h+='
'+c.n+'
';} if(c.d){h+='
';} if(c.d){h+='
🚗 '+c.d+'
';} if(c.t){h+='
'+formatTime(c.t)+'
';} if(!m){h+='
';} if(c.l){var z=c.s||'Read more';p='';if(m){p=' pt-2';} h+='';}} if(m){h+='
';} h+='
';return h;} document.addEventListener('shown.bs.modal',function(e){if(e.target.id.startsWith('contentMapModal_')){let m=e.target.id.replace('contentMapModal_','');let t=window.contentMaps[m];if(t){setTimeout(()=>{e.target.style.borderBottom='1px solid #eee';setTimeout(()=>{e.target.style.borderBottom='';},1);},1);}}});window.addEventListener('resize',function(){document.querySelectorAll('[id^="contentMapModal_"]').forEach(p=>{if(p.classList.contains('show')){let m=p.id.replace('contentMapModal_','');let t=window.contentMaps[m];if(t){setTimeout(()=>{t.style.borderBottom='1px solid #eee';setTimeout(()=>{t.style.borderBottom='';},1);},1);}}});});function mDev(){return window.innerWidth<=768||window.innerHeight<=600;} async function updateMapBounds(m,n){const map=contentMaps[m];const oldBounds=contentMaps[m].getBounds();var T=contentMaps[m].getBounds();const D=contentMaps[m].getContainer().getBoundingClientRect();const x=markerData[m][n];const lngDiff=oldBounds.getNorthEast().lng-oldBounds.getSouthWest().lng;const latDiff=oldBounds.getNorthEast().lat-oldBounds.getSouthWest().lat;const lngPerPx=lngDiff / D.width;const latPerPx=latDiff / D.height;const U=[];var B=new mapboxgl.LngLatBounds(T.toArray());var R=new mapboxgl.LngLatBounds(T.toArray());if(!mDev()&&markerData[m][n].c.card&&markerData[m][n].a){const cP=new Promise(async(resolve)=>{const h=await new Promise(resolveHeight=>{const hInt=setInterval(()=>{let chk=markerData[m][n].c.card.height;if(chk){clearInterval(hInt);resolveHeight(chk);}},100);});const w=300;var p=15;const z=contentMaps[m].getZoom();var a=0;if(z<7){a=(8-z)*10;} const oX=markerData[m][n].c.card.oX;const oY=markerData[m][n].c.card.oY;const P=map.project(new mapboxgl.LngLat(x.lonLat[0],x.lonLat[1]));const tG=P.y+oY-h if(tG{const jR=await new Promise(resolve=>{const intervalId=setInterval(()=>{if(x.c.route.json&&Array.isArray(x.c.route.json)&&x.c.route.json.length>0){clearInterval(intervalId);resolve(true);}},100);});if(jR){const paddingRoutePixels=20;let extendWest=false,extendEast=false,extendNorth=false,extendSouth=false;x.c.route.json.forEach(coord=>{if(coord[0]R.getEast())extendEast=true;if(coord[1]>R.getNorth())extendNorth=true;if(coord[1]status)){T.extend(B.getSouthWest());T.extend(B.getNorthEast());T.extend(R.getSouthWest());T.extend(R.getNorthEast());map.fitBounds(T,{padding:0,duration:600,easing:(t)=>t*(2-t)});}}const markerConfig={'finish':{className:'marker_finish',size:[58,58],offset:[0,-29],span:false,best:false,text:false,},'start':{className:'marker_start',size:[58,58],offset:[0,-29],span:false,best:false,text:false,},'star':{className:'marker_star',size:[58,58],offset:[0,-29],span:false,best:false,text:false,},'numbered':{className:'mapMarkerNum',size:false,offset:[0,0],span:true,best:true,text:false,},'star-plain':{className:'mapMarkerNum markerSpanRed',size:false,offset:[0,0],span:true,best:false,text:'☆',},'grey':{className:'mapMarkerNum markerSpanGrey',size:false,offset:[0,0],span:true,best:false,text:false,},};function addMarkersToMap(m,f=null){Object.values(markerData[m]).forEach((i,n)=>{if(f!==null&&n'+t+'';} if(mC.width&&mC.height){el.style.width=mC.width+'px';el.style.height=mC.height+'px';} var marker=new mapboxgl.Marker(el,{offset:mC.offset}).setLngLat(i.lonLat).addTo(window.contentMaps[m]);marker.markerType=i.iconType;if(f!==null){} i.marker=marker;window.bounds[m].extend(i.lonLat);if(i.c){marker.getElement().addEventListener('click',function(){event.stopPropagation();toggleMapIconClick(m,n,true);});}});}if(typeof window.contentMaps==='undefined'){window.contentMaps={};window.initialMapBounds={};} if(typeof window.bounds==='undefined'){window.bounds={};} if(typeof window.markerData==='undefined'){window.markerData={};} if(!markerData[1]){markerData[1]={};} function initMapbox_1(){mapboxgl.accessToken='pk.eyJ1IjoibGF6eXRyaXBzIiwiYSI6ImNsaTJ4anh2MTA5NDYzZW85ODJmMm45ZzcifQ.9u5pN47V7SsoFwF6_Pw5bQ';const contentMap_1=new mapboxgl.Map({container:'contentMap_1',style:'mapbox://styles/mapbox/streets-v11',center:[-100.05399645604084,42.07009975534783],zoom:5,cooperativeGestures:false});window.contentMaps[1]=contentMap_1;if(typeof window.bounds[1]==='undefined'){window.bounds[1]=new mapboxgl.LngLatBounds();} markerData[1][0]={"lonLat":[-79.38592946,43.65520016],"type":"star-plain"};markerData[1][1]={"lonLat":[-79.0378776557006,43.09504950284698],"best":1,"time":170,"distance":170,"type":"numbered","c":{"route":{"id":1153,"color":"#fa5050"},"card":{"title":"Niagara Falls","d":"170 miles","t":170,"p":"[\"cca93bca20cbd868091620d3b460d72a\",\"Spectacular Niagara Falls between USA and Canada less than 2 hours' road trip from Toronto\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-niagara-falls","linkText":"Read more"}}};markerData[1][2]={"lonLat":[-83.04788133,42.33291587],"best":2,"time":285,"distance":447,"type":"numbered","c":{"route":{"id":1561,"color":"#fa5050"},"card":{"title":"Detroit","d":"447 miles","t":285,"p":"[\"72d8b91c1432c21aa38f2868cc794d70\",\"View of Michigan Labor Legacy Monument on Hart Plaza near river embarkment in Detroit, USA.\"]","oX":175,"oY":0}}};markerData[1][3]={"lonLat":[-73.99536314005394,40.75678782492213],"best":3,"time":480,"distance":860,"type":"numbered","c":{"route":{"id":43,"color":"#fa5050"},"card":{"title":"New York","d":"860 miles","t":480,"p":"[\"210ff22d1f0ca877927934c95793f1da\",\"Route 97 in Catskills Mountains winding along river Delaware in upstate New York\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-new-york","linkText":"Read more"}}};markerData[1][4]={"lonLat":[-75.69730933268605,45.42279649786122],"best":4,"time":260,"distance":450,"type":"numbered","c":{"route":{"id":720,"color":"#fa5050"},"card":{"title":"Ottawa","d":"450 miles","t":260,"p":"[\"6e24d5bff80e9afc7403a112d877684e\",\"Ottawa in winter at dusk with a purple-hued sky and the water in the foreground\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-ottawa","linkText":"Read more"}}};markerData[1][5]={"lonLat":[-63.644043881443345,44.64752323656805],"best":5,"time":1215,"distance":1985,"type":"numbered","c":{"route":{"id":93,"color":"#fa5050"},"card":{"title":"Nova Scotia","d":"1,985 miles","t":1215,"p":"[\"2d8280c3fd55c7ee6190e550c3a044aa\",\"Scenic lighthouse by the water with an autumnal forest in the background\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-nova-scotia","linkText":"Read more"}}};markerData[1][6]={"lonLat":[-78.37893544,45.83722567],"best":6,"time":200,"distance":306,"type":"numbered","c":{"route":{"id":1521,"color":"#fa5050"},"card":{"title":"Algonquin Provincial Park","d":"306 miles","t":200,"p":"[\"57cf816d63bafc481455a4fa7d387e67\",\"Lake surrounded by forest in Algonquin Provincial Park, 3 hours drive from Toronto\"]","oX":175,"oY":0}}};markerData[1][7]={"lonLat":[-73.60064472324481,45.47302343221755],"best":7,"time":390,"distance":600,"type":"numbered","c":{"route":{"id":41,"color":"#fa5050"},"card":{"title":"Montreal","d":"600 miles","t":390,"p":"[\"6d73a3240659021e844fc3ca31ee56a6\",\"High rise downtown buildings with sliver of water behind and pink and gold sky\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-montreal","linkText":"Read more"}}};markerData[1][8]={"lonLat":[-87.67605195263806,41.929854275727834],"best":8,"time":800,"distance":1120,"type":"numbered","c":{"route":{"id":2251,"color":"#fa5050"},"card":{"title":"Chicago","d":"1,120 miles","t":800,"p":"[\"9659851cb3a998c9abe4417b6da6693a\",\"Chicago skyline aerial drone view from above, lake Michigan and city of Chicago downtown skyscrapers cityscape bird's view from park, Illinois, USA\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-chicago","linkText":"Read more"}}};markerData[1][9]={"lonLat":[-78.8867306931584,33.68919303899491],"best":9,"time":1170,"distance":1640,"type":"numbered","c":{"route":{"id":2250,"color":"#fa5050"},"card":{"title":"Myrtle Beach","d":"1,640 miles","t":1170,"p":"[\"070f14afb6c1535850658658a14f37d1\",\"Myrtle Beach, South Carolina, USA city skyline.\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-myrtle-beach","linkText":"Read more"}}};markerData[1][10]={"lonLat":[-89.99583644936847,29.9756229066103],"best":10,"time":1200,"distance":2090,"type":"numbered","c":{"route":{"id":366,"color":"#fa5050"},"card":{"title":"New Orleans","d":"2,090 miles","t":1200,"p":"[\"182424d6505717b3807e3548e4cd0519\",\"New Orleans, Louisiana, USA with a streetcar in downtown New Orleans on Canal Street on a sunny day with buildings in the background.\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-new-orleans","linkText":"Read more"}}};markerData[1][11]={"lonLat":[-60.21317,46.22176],"best":11,"time":1740,"distance":2325,"type":"numbered","c":{"route":{"id":815,"color":"#fa5050"},"card":{"title":"Newfoundland","d":"2,325 miles","t":1740,"p":"[\"1f563250934f6ea683d8bf58c668eb64\",\"The fishing village of Tilting, Fogo Island,with two red cabins on the water\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-newfoundland","linkText":"Read more"}}};markerData[1][12]={"lonLat":[-76.00865934804857,44.365778937687],"best":12,"time":270,"distance":354,"type":"numbered","c":{"route":{"id":1558,"color":"#fa5050"},"card":{"title":"Thousand Islands","d":"354 miles","t":270,"p":"[\"7652c176a743bf443f93a03710b85e76\",\"Boldt Castle on Heart Island in the St Lawrence River, USA\"]","oX":175,"oY":0,"link":"","linkText":"Read more"}}};markerData[1][13]={"lonLat":[-86.82554267482128,36.10756858387508],"best":13,"time":710,"distance":1231,"type":"numbered","c":{"route":{"id":894,"color":"#fa5050"},"card":{"title":"Nashville","d":"1,231 miles","t":710,"p":"[\"f79ebb1c678b42377c398d3bbf4b8894\",\"Nashville, Tennessee, USA with neon signs on Lower Broadway Area at night.\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-nashville","linkText":"Read more"}}};markerData[1][14]={"lonLat":[-71.08800488881784,46.81085037550188],"best":14,"time":480,"distance":800,"type":"numbered","c":{"route":{"id":132,"color":"#fa5050"},"card":{"title":"Quebec City","d":"800 miles","t":480,"p":"[\"86ec9f9bef940e673c2454d562381e53\",\"Frontenac Castle in Old Quebec City at sunrise - at the end of a road trip from Toronto\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-quebec-city","linkText":"Read more"}}};markerData[1][15]={"lonLat":[-77.03384875425135,38.90287414388599],"best":15,"time":540,"distance":805,"type":"numbered","c":{"route":{"id":942,"color":"#fa5050"},"card":{"title":"Washington DC","d":"805 miles","t":540,"p":"[\"9a983171089ab684d0f976eb1546da3f\",\"Washington DC, US Capitol Building in a cloudy sunrise with mirror reflection\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-washington-dc","linkText":"Read more"}}};markerData[1][16]={"lonLat":[-77.98164694331562,43.62409295519985],"best":16,"time":630,"distance":917,"type":"numbered","c":{"route":{"id":1562,"color":"#fa5050"},"card":{"title":"Lake Ontario","d":"917 miles","t":630,"p":"[\"d43e5f21851c392f3aeff8110298a2ea\",\"Bright sky at sunset and lamp on the shore of Lake Ontario in Canada\"]","oX":175,"oY":0}}};markerData[1][17]={"lonLat":[-81.5453945746534,45.220324759975774],"best":17,"time":220,"distance":298,"type":"numbered","c":{"route":{"id":1559,"color":"#fa5050"},"card":{"title":"Bruce Peninsula National Park","d":"298 miles","t":220,"p":"[\"30bdbb89a876475eb887467f587ff439\",\"Cove Island Lighthouse off Bruce Peninsula in Ontario, 3 hours away from Toronto\"]","oX":175,"oY":0,"link":"","linkText":"Read more"}}};markerData[1][18]={"lonLat":[-86.09121692506969,42.837883204251334],"best":18,"time":1560,"distance":2650,"type":"numbered","c":{"route":{"id":1568,"color":"#fa5050"},"card":{"title":"Lake Michigan and Lake Huron","d":"2,650 miles","t":1560,"p":"[\"8b9fd521db3ea640def7424342825348\",\"Chicago skyline with skyscrapers facing Lake Michigan\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-around-lake-michigan","linkText":"Read more"}}};markerData[1][19]={"lonLat":[-81.38747209885473,28.554610290790066],"best":19,"time":1295,"distance":2130,"type":"numbered","c":{"route":{"id":57,"color":"#fa5050"},"card":{"title":"Orlando","d":"2,130 miles","t":1295,"p":"[\"9c3ba11442c15c69a79e5dbc93c63756\",\"View of Orlando skyline with holiday decorations on palm trees at sunset\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-orlando","linkText":"Read more"}}};markerData[1][20]={"lonLat":[-71.05208826178469,42.343273189392974],"best":20,"time":690,"distance":980,"type":"numbered","c":{"route":{"id":2253,"color":"#fa5050"},"card":{"title":"Boston","d":"980 miles","t":690,"p":"[\"544e397f563a675008e11980340d76f4\",\"The famous Universal Globe at Universal Studios Florida theme park\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-boston","linkText":"Read more"}}};markerData[1][21]={"lonLat":[-82.03669872552638,45.70932688865071],"best":21,"time":390,"distance":596,"type":"numbered","c":{"route":{"id":1560,"color":"#fa5050"},"card":{"title":"Manitoulin Island","d":"596 miles","t":390,"p":"[\"5cdace0c338a0df707330055c65a420f\",\"Little Current Swing Bridge carrying Highway 6 from Goat Island to Manitoulin Island\"]","oX":175,"oY":0,"link":"","linkText":"Read more"}}};markerData[1][22]={"lonLat":[-75.17295128010913,39.970327868323615],"best":22,"time":660,"distance":1046,"type":"numbered","c":{"route":{"id":796,"color":"#fa5050"},"card":{"title":"Philadelphia","d":"1,046 miles","t":660,"p":"[\"4cb1ffe65807af11c4b90bed01b4e99a\",\"Liberty Bell old symbol of American freedom in Philadelphia Pennsylvania, USA\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-philadelphia","linkText":"Read more"}}};markerData[1][23]={"lonLat":[-74.0423233504327,40.717679406837064],"best":23,"time":700,"distance":1054,"type":"numbered","c":{"route":{"id":1042,"color":"#fa5050"},"card":{"title":"New Jersey","d":"1,054 miles","t":700,"p":"[\"ec323938c1dbc6e06f1b396347fd20e8\",\"Boaters docking at the Main Lake Market, a convenience store and caf\\u00e9, along the banks of Lake Hopatcong, New Jersey\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-new-jersey","linkText":"Read more"}}};markerData[1][24]={"lonLat":[-80.19190248410781,25.76173008913324],"best":24,"time":1680,"distance":1670,"type":"numbered","c":{"route":{"id":1147,"color":"#fa5050"},"card":{"title":"Miami","d":"1,670 miles","t":1680,"p":"[\"e70b5af642f2f2c1634cd95b3a065e31\",\"Ocean Drive in Miami Florida, with a vintage car parked on the palm-lined street\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-miami","linkText":"Read more"}}};markerData[1][25]={"lonLat":[-79.60041317945928,45.11551224285904],"best":25,"time":130,"distance":208,"type":"numbered","c":{"route":{"id":1500,"color":"#fa5050"},"card":{"title":"Muskoka","d":"208 miles","t":130,"p":"[\"958d1aa54bf8de3f273e8417c20e4714\",\"A road through a gold forest in the fall in Muskoka, Ontario, Canada\"]","oX":175,"oY":0,"link":"","linkText":"Read more"}}};markerData[1][26]={"lonLat":[-81.69455659236199,41.49929265874637],"best":26,"time":410,"distance":550,"type":"numbered","c":{"route":{"id":933,"color":"#fa5050"},"card":{"title":"Cleveland","d":"550 miles","t":410,"p":"[\"4bac4129f382c41ac8a36b6700ae042f\",\"Cleveland, Ohio, USA skyline on the Cuyahoga River.\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-cleveland","linkText":"Read more"}}};markerData[1][27]={"lonLat":[-76.17345371712786,44.33143180580409],"best":27,"time":243,"distance":311,"type":"numbered","c":{"route":{"id":1522,"color":"#fa5050"},"card":{"title":"Gananoque","d":"311 miles","t":243,"p":"[\"cd9badf768bfb3a576da10fd815a1e46\",\"Vineyard in Prince Edward County in Ontario with a keg at the front\"]","oX":175,"oY":0,"link":"","linkText":"Read more"}}};initialMapBounds[1]=new mapboxgl.LngLatBounds(window.bounds[1].getSouthWest(),window.bounds[1].getNorthEast());const visibleMapRoutes_1=[];contentMaps[1].on('click',(e)=>{resetMarkersAndCards(1);});onMapZoom(1);markerData[1][33]={"lonLat":[-71.05502,48.433494],"time":1920,"distance":2850,"type":"grey","c":{"route":{"id":1567,"color":"#fa5050"},"card":{"title":"Quebec and Saguenay Fjord","d":"2,850 miles","t":1920,"p":"[\"a7c82e68f232051a38c1c7fc571173d8\",\"Mont Tremblant town, view of the lake and National Park in the fall\"]","oX":175,"oY":0,"link":"","linkText":"Read more"}}};markerData[1][28]={"lonLat":[-114.00640933749531,51.0372261082278],"time":1980,"distance":3300,"type":"grey","c":{"route":{"id":148,"color":"#fa5050"},"card":{"title":"Calgary","d":"3,300 miles","t":1980,"p":"[\"b7fa53cd027352272008b8d164f0bb3f\",\"Skyline of Calgary and famous red bridge during sunset\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-calgary","linkText":"Read more"}}};markerData[1][29]={"lonLat":[-115.54447928790215,51.17670626918203],"time":2040,"distance":3420,"type":"grey","c":{"route":{"id":814,"color":"#fa5050"},"card":{"title":"Banff","d":"3,420 miles","t":2040,"p":"[\"1be2715b551e2d147387a453b3f7a314\",\"Banff, Rocky Mountains, Alberta, Canada with Bow Lake near Icefields Parkway, mountains in the distance, purple flowers in the foreground and taken on a sunny clear day.\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-banff","linkText":"Read more"}}};markerData[1][30]={"lonLat":[-91.131656,48.675711],"time":2160,"distance":3450,"type":"grey","c":{"route":{"id":1566,"color":"#fa5050"},"card":{"title":"Thunder Bay and Quetico Provincial Park","d":"3,450 miles","t":2160,"p":"[\"d42d9c45d8dc3adc6a1538dfc39d431e\",\"Canoe and oar on the rocks of Knife Lake in Quetico Provincial Park, Canada\"]","oX":175,"oY":0,"link":"","linkText":"Read more"}}};markerData[1][31]={"lonLat":[-118.2878706555082,34.064779449589],"time":4345,"distance":2700,"type":"grey","c":{"route":{"id":2252,"color":"#fa5050"},"card":{"title":"Los Angeles","d":"2,700 miles","t":4345,"p":"[\"f5a3aeaca12453889bb32b18c59bdc16\",\"Santa Monica Pier is one of the many amazing places to see in Los Angeles on the way from San Diego to Santa Barbara.\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-los-angeles","linkText":"Read more"}}};markerData[1][32]={"lonLat":[-123.1019456342191,49.29169970320409],"time":2700,"distance":4465,"type":"grey","c":{"route":{"id":100,"color":"#fa5050"},"card":{"title":"Vancouver","d":"4,465 miles","t":2700,"p":"[\"fac7f1e6e510e9ebbd121b0650fc6f49\",\"Vancouver skyline at dusk reflected in a lake surface\"]","oX":175,"oY":0,"link":"\/trip\/road-trip-from-toronto-to-vancouver","linkText":"Read more"}}};addMarkersToMap(1);contentMap_1.fitBounds(window.bounds[1],{padding:{top:60,bottom:60,left:60,right:60}});const sortByValue=document.querySelector('.cardListSortDropdown').value;sortMapMarkers(markerData,sortOptionsMap,sortByValue,1);}const sortOptionsMap={'best':'best','distance':'distanceSort',};function sortMapMarkers(markerData,sortOptionsMap,sortBy,listNum){const markersWithDistance=Object.values(markerData[listNum]).filter(marker=>marker.hasOwnProperty('distance')&&marker.hasOwnProperty('best'));const hasDistanceSort=markersWithDistance.some(marker=>marker.hasOwnProperty('distanceSort'));if(!hasDistanceSort){const sortedMarkers=markersWithDistance.sort((a,b)=>a.distance-b.distance);sortedMarkers.forEach((sortedMarker,index)=>{sortedMarker.distanceSort=index+1;});} Object.keys(markerData[listNum]).forEach(n=>{const marker=markerData[listNum][n];if(marker.hasOwnProperty('distance')&&marker.hasOwnProperty('best')){const markerElement=document.getElementById('markerSpan-'+listNum+'-'+n);if(markerElement){const propertyToUse=sortOptionsMap[sortBy]||sortBy;const v=marker[propertyToUse];if(v!==undefined){markerElement.innerHTML=v;}else{markerElement.innerHTML='';}}}});document.querySelectorAll('.cardListSortDropdown').forEach(function(dropdownUpdate){dropdownUpdate.value=sortBy;});} (function(){function iSort(){document.querySelectorAll('.cardListSortDropdown').forEach(function(dropdown){dropdown.addEventListener('change',function(){const sortBy=this.value;const listNum=this.getAttribute('data-listnum');const cardsContainer=document.querySelector('.row[data-listnum=\"'+listNum+'\"]');Array.from(cardsContainer.children).sort((a,b)=>{const aValue=parseFloat(a.getAttribute('data-'+sortBy)||Infinity);const bValue=parseFloat(b.getAttribute('data-'+sortBy)||Infinity);return aValue-bValue;}).forEach((card,index)=>{cardsContainer.appendChild(card);const titleElement=card.querySelector('.card-title');if(titleElement){const updatedTitle=titleElement.innerHTML.replace(/^\s*\d+/,index+1);titleElement.innerHTML=updatedTitle;}});sortMapMarkers(markerData,sortOptionsMap,sortBy,listNum);});});} if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',iSort);}else{iSort();}})(); var mapScriptCreated = 0; var mapCssCreated = 0; var mapScriptLoaded = 0; var mapCssLoaded = 0; var mapLoadList = []; function showLazyMap(fname) { if (mapScriptLoaded == 1 && mapCssLoaded == 1) { if (!mapLoadList.includes(fname)) { window[fname](); mapLoadList.push(fname); } } } (function fn() { var pics = document.querySelectorAll('.no-js-hide'); pics.forEach(function(pic) { pic.classList.toggle('no-js-hide'); }); var lazyImages = [].slice.call(document.querySelectorAll(".lazeeload")); if ("IntersectionObserver" in window) { const config = { root: null, rootMargin: '1000px', threshold: 0 }; let lazyImageObserver = new IntersectionObserver(function(entries, observer) { entries.forEach(function(entry) { if (entry.isIntersecting) { let lazyImage = entry.target; if (lazyImage.dataset.src) {lazyImage.src = lazyImage.dataset.src;} if (lazyImage.dataset.srcset) {lazyImage.srcset = lazyImage.dataset.srcset;} if (lazyImage.dataset.map) { const fname = "initMapbox_"+lazyImage.dataset.map; if (mapScriptLoaded == 0) { let script = document.createElement('script'); script.async=true; script.defer=true; script.src = "https://api.mapbox.com/mapbox-gl-js/v3.0.0/mapbox-gl.js"; script.onload = function(){ mapScriptLoaded = 1; showLazyMap(fname); } document.head.appendChild(script); mapScriptCreated = 1; let css = document.createElement('link'); css.rel = "stylesheet"; css.href = "https://api.mapbox.com/mapbox-gl-js/v3.0.0/mapbox-gl.css"; css.onload = function(){ mapCssLoaded = 1; showLazyMap(fname); } document.head.appendChild(css); mapCssCreated = 1; } else { if (typeof window[fname] === 'function') { window[fname](); } showLazyMap(fname); } } lazyImage.classList.remove("no-js-hide"); lazyImage.classList.remove("lazeeload"); lazyImageObserver.unobserve(lazyImage); } }); }, config); lazyImages.forEach(function(lazyImage) { lazyImageObserver.observe(lazyImage); lazyImage.classList.add("lazeeload-activated"); }); } else { let active = false; const lazyLoad = function() { if (active === false) { active = true; setTimeout(function() { lazyImages.forEach(function(lazyImage) { if ((lazyImage.getBoundingClientRect().top <= window.innerHeight+1000 && lazyImage.getBoundingClientRect().bottom >= 0) && getComputedStyle(lazyImage).display !== "none") { if (lazyImage.dataset.src) lazyImage.src = lazyImage.dataset.src; if (lazyImage.dataset.srcset) lazyImage.srcset = lazyImage.dataset.srcset; if (lazyImage.dataset.onload) lazyImage.onload = lazyImage.dataset.onload; lazyImage.classList.remove("lazeeload"); lazyImages = lazyImages.filter(function(image) { return image !== lazyImage; }); if (lazyImages.length === 0) { document.removeEventListener("scroll", lazyLoad); window.removeEventListener("resize", lazyLoad); window.removeEventListener("orientationchange", lazyLoad); } } }); active = false; }, 200); } }; document.addEventListener("scroll", lazyLoad); window.addEventListener("resize", lazyLoad); window.addEventListener("orientationchange", lazyLoad); } var lazyImages = [].slice.call(document.querySelectorAll(".lazeeload")); i=1; lazyImages.forEach(function(lazyImage) { if (!(lazyImage.classList.contains("lazeeload-activated"))) { if (lazyImage.dataset.src) lazyImage.src = lazyImage.dataset.src; if (lazyImage.dataset.srcset) lazyImage.srcset = lazyImage.dataset.srcset; lazyImage.classList.remove("lazeeload"); } }); })(); document.addEventListener('DOMContentLoaded', () => { const h = document.querySelector('header.fixed-top'), o = getComputedStyle(h).right; ['show.bs.modal', 'hidden.bs.modal'].forEach(e => document.querySelectorAll('.fullScreenModal').forEach(m => m.addEventListener(e, ev => h.style.right = ev.type === 'show.bs.modal' ? `${window.innerWidth - document.documentElement.clientWidth}px` : o))); });