function mapClickSim(m,i){$('#contentMapModal_'+m).modal('show');function w(){if(window.contentMaps[m]!==undefined&&typeof toggleMapIconClick==="function"&&typeof resetMarkersAndCards==="function"){resetMarkersAndCards(m);toggleMapIconClick(m,i);}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));}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:[-95.54884658007248,39.26280360374335],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":[" -94.58013940823928","39.10035917187253"],"type":"star-plain"};markerData[1][1]={"lonLat":[" -92.79296570449453","38.12548541669631"],"best":"1","time":"150","distance":150,"type":"numbered","onClick":true,"route":{"id":"2519","color":"#fa5050"},"card":{"title":"Lake of the Ozarks","distanceTime":"\ud83d\ude97 150 miles \u23f1\ufe0f 2 hours, 30 minutes","photoCode":"\"Lone","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};function getNewLngLat(map,originalLngLat,offsets){var pixel=map.project(new mapboxgl.LngLat(originalLngLat[0],originalLngLat[1]));pixel.x+=offsets.x;pixel.y+=offsets.y;return map.unproject(pixel);} Object.keys(contentMaps).forEach(function(mapNum){contentMaps[mapNum].on('zoom',function(){Object.keys(markerData[mapNum]).forEach(function(iconNum){var marker=markerData[mapNum][iconNum];if(!isMobileDevice()&&marker.cardInstance){var offsets={x:marker.card.oX,y:marker.card.oY};var newLngLat=getNewLngLat(contentMaps[mapNum],marker.lonLat,offsets);marker.cardInstance.setLngLat([newLngLat.lng,newLngLat.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 data=await r.json();if(data.response&&data.response.route){const d=JSON.parse(data.response.route);markerData[m][i].routeJson=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,iconNum){if(markerData[m][iconNum].a){return;} for(const[key,icon]of Object.entries(markerData[m])){if(parseInt(key)===iconNum){continue;} if(icon.popupInstance){icon.popupInstance.remove();delete icon.popupInstance;} if(icon.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 overlayToRemove=icon.cardOverlay;if(overlayToRemove&&overlayToRemove.parentNode){overlayToRemove.parentNode.removeChild(overlayToRemove);delete icon.cardOverlay;}} icon.a=false;} if(!markerData[m][iconNum].a){markerData[m][iconNum].marker.getElement().classList.add('markerSpanSelect');if(markerData[m][iconNum].popup){const t=markerData[m][iconNum].popup.title;const p=markerData[m][iconNum].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][iconNum].lonLat).setHTML(popupHTML).addTo(contentMaps[m]);markerData[m][iconNum].popupInstance=popup;popup._content.addEventListener('click',function(){toggleMapIconClick(m,iconNum);});markerData[m][iconNum].marker.getElement().style.display='none';} if(markerData[m][iconNum].route){const layerId='iconRoute_'+m+'_'+iconNum;if(contentMaps[m].getLayer(layerId)){contentMaps[m].setLayoutProperty(layerId,'visibility','visible');}else{fetchRoute(markerData[m][iconNum].route.id,m,iconNum,markerData[m][iconNum].route.color);}} if(markerData[m][iconNum].card){var cardContent={cardTitle:markerData[m][iconNum].card.title,cardDistanceTime:markerData[m][iconNum].card.distanceTime,photoCode:markerData[m][iconNum].card.photoCode,};if(markerData[m][iconNum].hasOwnProperty('cardLink')){cardContent.cardLink=markerData[m][iconNum].cardLink;} if(markerData[m][iconNum].hasOwnProperty('cardLinkText')){cardContent.cardLinkText=markerData[m][iconNum].cardLinkText;} if(!isMobileDevice()){var cardContentHtml=createCardContentHtml(cardContent,false);var offsets={x:markerData[m][iconNum].card.oX,y:markerData[m][iconNum].card.oY};var newLngLat=getNewLngLat(contentMaps[m],markerData[m][iconNum]['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][iconNum].cardInstance=cardPopup;}else{var cardMobile=document.createElement('div');cardMobile.className='mapPopupCardMobile';cardMobile.innerHTML=createCardContentHtml(cardContent,true);var mapContainer=contentMaps[m].getContainer();mapContainer.appendChild(cardMobile);markerData[m][iconNum].cardOverlay=cardMobile;}} markerData[m][iconNum].a=true;updateMapBounds(m,iconNum);}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].route){if(contentMaps[m].getLayer('iconRoute_'+m+'_'+i)){hideRouteLayer(m,i);}} if(markerData[m][i].card){if(markerData[m][i].cardInstance){markerData[m][i].cardInstance.remove();delete markerData[m][i].cardInstance;}} if(markerData[m][i].cardOverlay){var overlayToRemove=markerData[m][i].cardOverlay;if(overlayToRemove&&overlayToRemove.parentNode){overlayToRemove.parentNode.removeChild(overlayToRemove);delete markerData[m][i].cardOverlay;}} markerData[m][i].marker.getElement().style.display='block';markerData[m][i].a=false;if(markerData[m][i].best){updateMapBounds(m,i);}});} function createCardContentHtml(c,m){let htmlContent='
';if(c.photoCode){htmlContent+='
'+c.photoCode+'
';} if(c.cardTitle||c.cardDistanceTime||c.cardLink){htmlContent+='
';if(c.cardTitle){htmlContent+='
'+c.cardTitle+'
';} if(c.cardDistanceTime){if(m){const parts=c.cardDistanceTime.split('⏱️');htmlContent+='
'+parts[0].trim()+'
⏱️ '+parts[1].trim()+'
';}else{htmlContent+='
'+c.cardDistanceTime+'
';}} if(c.cardLink){var linkText=c.cardLinkText||'Read more';htmlContent+=''+linkText+'';} htmlContent+='
';} htmlContent+='
';return htmlContent;} $(document).on('shown.bs.modal','[id^=contentMapModal_]',function(){let modalId=$(this).attr('id');let mapNum=modalId.replace('contentMapModal_','');if(window.contentMaps&&window.contentMaps[mapNum]){window.contentMaps[mapNum].resize();Object.keys(markerData[mapNum]).forEach((i)=>{updateMapBounds(mapNum,i);});}});$(document).on('hidden.bs.modal','[id^=contentMapModal_]',function(){resetMarkersAndCards($(this).attr('id').replace('contentMapModal_',''));});function isMobileDevice(){return window.innerWidth<=768||window.innerHeight<=600;} function updateMapBounds(mapNum,iconNum){const oldBounds=contentMaps[mapNum].getBounds();const newBounds=contentMaps[mapNum].getBounds();const mapDimensions=contentMaps[mapNum].getContainer().getBoundingClientRect();const clickedMarker=markerData[mapNum][iconNum];const lngDiff=oldBounds.getNorthEast().lng-oldBounds.getSouthWest().lng;const latDiff=oldBounds.getNorthEast().lat-oldBounds.getSouthWest().lat;const lngPerPx=lngDiff / mapDimensions.width;const latPerPx=latDiff / mapDimensions.height;if(clickedMarker['popup']&&clickedMarker.a){const pixelCoordinates=contentMaps[mapNum].project(clickedMarker.lonLat);const tooCloseX=100;const tooCloseT=80;const tooCloseB=10;const eXp=120;const eTp=120;const eBp=20;const extendNWSE=[0,0,0,0];if(pixelCoordinates.xmapDimensions.width-tooCloseX){extendNWSE[1]=eXp-(mapDimensions.width-pixelCoordinates.x);} if(pixelCoordinates.ymapDimensions.height-tooCloseB){extendNWSE[2]=eBp-(mapDimensions.height-pixelCoordinates.y);} for(let i=0;i0){switch(i){case 0:const extendNorthLat=extendNWSE[i]*latPerPx;newBounds.extend(new mapboxgl.LngLat(clickedMarker.lonLat[0],oldBounds.getNorthEast().lat+extendNorthLat));break;case 1:const extendEastLng=extendNWSE[i]*lngPerPx;newBounds.extend(new mapboxgl.LngLat(oldBounds.getNorthEast().lng+extendEastLng,clickedMarker.lonLat[1]));break;case 2:const extendSouthLat=extendNWSE[i]*latPerPx;newBounds.extend(new mapboxgl.LngLat(clickedMarker.lonLat[0],oldBounds.getSouthWest().lat-extendSouthLat));break;case 3:const extendWestLng=extendNWSE[i]*lngPerPx;newBounds.extend(new mapboxgl.LngLat(oldBounds.getSouthWest().lng-extendWestLng,clickedMarker.lonLat[1]));break;}}} if(Math.abs(newBounds.getSouthWest().lng-oldBounds.getSouthWest().lng)>1e-6||Math.abs(newBounds.getSouthWest().lat-oldBounds.getSouthWest().lat)>1e-6||Math.abs(newBounds.getNorthEast().lng-oldBounds.getNorthEast().lng)>1e-6||Math.abs(newBounds.getNorthEast().lat-oldBounds.getNorthEast().lat)>1e-6){contentMaps[mapNum].fitBounds(newBounds,{padding:0,duration:600,easing:(t)=>t*(2-t)});}} if(clickedMarker['route']&&clickedMarker['routeJson']&&clickedMarker['clicked']){const paddingRoutePixels=20;let extendWest=false,extendEast=false,extendNorth=false,extendSouth=false;clickedMarker['routeJson'].forEach(coord=>{if(coord[0]newBounds.getEast())extendEast=true;if(coord[1]>newBounds.getNorth())extendNorth=true;if(coord[1]t*(2-t)});} if(!isMobileDevice()&&markerData[mapNum][iconNum].card&&markerData[mapNum][iconNum].a){const w=300;const h=360;const p=100;const oX=markerData[mapNum][iconNum].card.oX;const oY=markerData[mapNum][iconNum].card.oY;const markerPixel=contentMaps[mapNum].project(clickedMarker.lonLat);const topLeftPixel={x:markerPixel.x+oX-w/2-p,y:markerPixel.y+oY-h-p};const topRightPixel={x:topLeftPixel.x+w+(2*p),y:topLeftPixel.y};const bottomLeftPixel={x:topLeftPixel.x,y:topLeftPixel.y+h+(2*p)};const bottomRightPixel={x:topRightPixel.x,y:bottomLeftPixel.y};[topLeftPixel,topRightPixel,bottomLeftPixel,bottomRightPixel].forEach(pixel=>{const lngLat=contentMaps[mapNum].unproject(pixel);newBounds.extend(lngLat);});contentMaps[mapNum].fitBounds(newBounds,{padding:0,duration:600,easing:(t)=>t*(2-t)});}}markerData[1][2]={"lonLat":[" -90.20050816351198","38.62542410733092"],"best":"2","time":"220","distance":250,"type":"numbered","onClick":true,"route":{"id":"2524","color":"#fa5050"},"card":{"title":"St Louis","distanceTime":"\ud83d\ude97 250 miles \u23f1\ufe0f 3 hours, 40 minutes","photoCode":"\"St.","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][3]={"lonLat":[" -105.014249","39.740329"],"best":"3","time":"650","distance":730,"type":"numbered","onClick":true,"route":{"id":"2511","color":"#fa5050"},"card":{"title":"Denver","distanceTime":"\ud83d\ude97 730 miles \u23f1\ufe0f 10 hours, 50 minutes","photoCode":"\"Domed","oX":-175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-denver-colorado","cardLinkText":"Read more"};markerData[1][4]={"lonLat":[" -103.45094151355579","43.89592667816591"],"best":"4","time":"620","distance":730,"type":"numbered","onClick":true,"route":{"id":"2529","color":"#fa5050"},"card":{"title":"Mount Rushmore","distanceTime":"\ud83d\ude97 730 miles \u23f1\ufe0f 10 hours, 20 minutes","photoCode":"\"Mont","oX":-175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][5]={"lonLat":[" -87.629839","41.878095"],"best":"5","time":"540","distance":590,"type":"numbered","onClick":true,"route":{"id":"1437","color":"#fa5050"},"card":{"title":"Chicago","distanceTime":"\ud83d\ude97 590 miles \u23f1\ufe0f 9 hours","photoCode":"\"Chicago","oX":175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-chicago","cardLinkText":"Read more"};markerData[1][6]={"lonLat":[" -86.77683524664744","36.168130037826536"],"best":"6","time":"690","distance":660,"type":"numbered","onClick":true,"route":{"id":"2509","color":"#fa5050"},"card":{"title":"Nashville","distanceTime":"\ud83d\ude97 660 miles \u23f1\ufe0f 11 hours, 30 minutes","photoCode":"\"Colorful","oX":175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-nashville","cardLinkText":"Read more"};markerData[1][7]={"lonLat":[" -89.7712329623603","43.6275504291671"],"best":"7","time":"480","distance":510,"type":"numbered","onClick":true,"route":{"id":"2528","color":"#fa5050"},"card":{"title":"Wisconsin Dells","distanceTime":"\ud83d\ude97 510 miles \u23f1\ufe0f 8 hours","photoCode":"\"Wisconsin","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][8]={"lonLat":[" -93.6248627442705","41.58753869483123"],"best":"8","time":"170","distance":190,"type":"numbered","onClick":true,"route":{"id":"2521","color":"#fa5050"},"card":{"title":"Des Moines","distanceTime":"\ud83d\ude97 190 miles \u23f1\ufe0f 2 hours, 50 minutes","photoCode":"\"Des","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][9]={"lonLat":[" -96.79454795135207","32.77909192651216"],"best":"9","time":"490","distance":555,"type":"numbered","onClick":true,"route":{"id":"2531","color":"#fa5050"},"card":{"title":"Dallas","distanceTime":"\ud83d\ude97 555 miles \u23f1\ufe0f 8 hours, 10 minutes","photoCode":"\"Dallas,","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][10]={"lonLat":[" -95.934494","41.256548"],"best":"10","time":"480","distance":480,"type":"numbered","onClick":true,"route":{"id":"33","color":"#fa5050"},"card":{"title":"Omaha","distanceTime":"\ud83d\ude97 480 miles \u23f1\ufe0f 8 hours","photoCode":"\"Omaha,","oX":-175,"oY":-60},"cardLink":"\/trip\/road-trip-from-kansas-city-to-omaha","cardLinkText":"Read more"};markerData[1][11]={"lonLat":[" -93.21855127806485","36.64372305889135"],"best":"11","time":"345","distance":330,"type":"numbered","onClick":true,"route":{"id":"2507","color":"#fa5050"},"card":{"title":"Branson","distanceTime":"\ud83d\ude97 330 miles \u23f1\ufe0f 5 hours, 45 minutes","photoCode":"\"Branson,","oX":-175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-branson-missouri","cardLinkText":"Read more"};markerData[1][12]={"lonLat":[" -94.90170351029627","39.411295426305706"],"best":"12","time":"40","distance":35,"type":"numbered","onClick":true,"route":{"id":"2517","color":"#fa5050"},"card":{"title":"Weston","distanceTime":"\ud83d\ude97 35 miles \u23f1\ufe0f 40 minutes","photoCode":"\"Charming","oX":-175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][13]={"lonLat":[" -95.6752701207216","39.047373054555266"],"best":"13","time":"95","distance":85,"type":"numbered","onClick":true,"route":{"id":"2518","color":"#fa5050"},"card":{"title":"Topeka","distanceTime":"\ud83d\ude97 85 miles \u23f1\ufe0f 1 hour, 35 minutes","photoCode":"\"The","oX":-175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][14]={"lonLat":[" -92.741493","37.974960"],"best":"14","time":"160","distance":160,"type":"numbered","onClick":true,"route":{"id":"2520","color":"#fa5050"},"card":{"title":"Ha Ha Tonka State Park","distanceTime":"\ud83d\ude97 160 miles \u23f1\ufe0f 2 hours, 40 minutes","photoCode":"\"Crystal","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][15]={"lonLat":[" -94.52431208363184","39.429024028490204"],"best":"15","time":"40","distance":30,"type":"numbered","onClick":true,"route":{"id":"2516","color":"#fa5050"},"card":{"title":"Smithville Lake","distanceTime":"\ud83d\ude97 30 miles \u23f1\ufe0f 40 minutes","photoCode":"\"Reflection","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][16]={"lonLat":[" -94.22275132232986","36.37220194046162"],"best":"16","time":"190","distance":210,"type":"numbered","onClick":true,"route":{"id":"2522","color":"#fa5050"},"card":{"title":"Bentonville","distanceTime":"\ud83d\ude97 210 miles \u23f1\ufe0f 3 hours, 10 minutes","photoCode":"\"Bentonville,","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][17]={"lonLat":[" -91.77334468809055","37.951972526853794"],"best":"17","time":"210","distance":220,"type":"numbered","onClick":true,"route":{"id":"2523","color":"#fa5050"},"card":{"title":"Rolla","distanceTime":"\ud83d\ude97 220 miles \u23f1\ufe0f 3 hours, 30 minutes","photoCode":"\"Vintage","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][18]={"lonLat":[" -92.33760703642099","38.9595524351361"],"best":"18","time":"110","distance":125,"type":"numbered","onClick":true,"route":{"id":"2525","color":"#fa5050"},"card":{"title":"Columbia","distanceTime":"\ud83d\ude97 125 miles \u23f1\ufe0f 1 hour, 50 minutes","photoCode":"\"Columbia,","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][19]={"lonLat":[" -95.99276779973214","36.15402647950718"],"best":"19","time":"340","distance":340,"type":"numbered","onClick":true,"route":{"id":"2526","color":"#fa5050"},"card":{"title":"Tulsa","distanceTime":"\ud83d\ude97 340 miles \u23f1\ufe0f 5 hours, 40 minutes","photoCode":"\"Golden","oX":-175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][20]={"lonLat":[" -93.29443383580595","37.20814363105398"],"best":"20","time":"160","distance":170,"type":"numbered","onClick":true,"route":{"id":"2527","color":"#fa5050"},"card":{"title":"Springfield, Missouri","distanceTime":"\ud83d\ude97 170 miles \u23f1\ufe0f 2 hours, 40 minutes","photoCode":"\"Springfield,","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};initialMapBounds[1]=new mapboxgl.LngLatBounds(window.bounds[1].getSouthWest(),window.bounds[1].getNorthEast());const visibleMapRoutes_1=[];contentMaps[1].on('click',(e)=>{resetMarkersAndCards(1);});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;if(i.best){window.bounds[m].extend(i.lonLat);} if(i.onClick){marker.getElement().addEventListener('click',function(){event.stopPropagation();toggleMapIconClick(m,n);});}});} markerData[1][25]={"lonLat":[" -79.03867161154425","43.09680880777778"],"time":"880","distance":1005,"type":"grey","onClick":true,"route":{"id":"2530","color":"#fa5050"},"card":{"title":"Niagara Falls","distanceTime":"\ud83d\ude97 1,005 miles \u23f1\ufe0f 14 hours, 40 minutes","photoCode":"\"Beautiful","oX":175,"oY":0},"cardLink":"#","cardLinkText":""};markerData[1][21]={"lonLat":[" -110.580378","44.434138"],"time":"1110","distance":1230,"type":"grey","onClick":true,"route":{"id":"783","color":"#fa5050"},"card":{"title":"Yellowstone National Park","distanceTime":"\ud83d\ude97 1,230 miles \u23f1\ufe0f 18 hours, 30 minutes","photoCode":"\"Yellowstone","oX":-175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-yellowstone-national-park","cardLinkText":"Read more"};markerData[1][22]={"lonLat":[" -115.143064","36.180152"],"time":"1180","distance":1350,"type":"grey","onClick":true,"route":{"id":"781","color":"#fa5050"},"card":{"title":"Las Vegas","distanceTime":"\ud83d\ude97 1,350 miles \u23f1\ufe0f 19 hours, 40 minutes","photoCode":"\"Las","oX":-175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-las-vegas","cardLinkText":"Read more"};markerData[1][23]={"lonLat":[" -81.376704","28.539182"],"time":"1680","distance":1650,"type":"grey","onClick":true,"route":{"id":"400","color":"#fa5050"},"card":{"title":"Orlando","distanceTime":"\ud83d\ude97 1,650 miles \u23f1\ufe0f 28 hours","photoCode":"\"Orlando,","oX":175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-orlando-florida","cardLinkText":"Read more"};markerData[1][24]={"lonLat":[" -118.23846161102017","34.072569986096575"],"time":"1620","distance":1795,"type":"grey","onClick":true,"route":{"id":"2515","color":"#fa5050"},"card":{"title":"Los Angeles","distanceTime":"\ud83d\ude97 1,795 miles \u23f1\ufe0f 27 hours","photoCode":"\"Beautiful","oX":-175,"oY":0},"cardLink":"\/trip\/road-trip-from-kansas-city-to-los-angeles","cardLinkText":"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(iconNum=>{const marker=markerData[listNum][iconNum];if(marker.hasOwnProperty('distance')&&marker.hasOwnProperty('best')){const markerElement=document.getElementById('markerSpan-'+listNum+'-'+iconNum);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 initializeSortDropdown(){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.cardListCardTitle');if(titleElement){const updatedTitle=(index+1)+titleElement.innerHTML.replace(/^\d+\./,'.');titleElement.innerHTML=updatedTitle;}});sortMapMarkers(markerData,sortOptionsMap,sortBy,listNum);});});} if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',initializeSortDropdown);}else{initializeSortDropdown();}})(); 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"); } }); })();