๐ŸŒ GIS โ€” Jamaica Agricultural Map
Farms ยท Markets ยท Cold Storage ยท Agro Parks ยท Labor Zones ยท Export Points
Farm Agro Park Market Cold Storage Labor Zone Export Port Research Station Parish Capital
`).join('');});} function toggleFAQ(el){const a=el.nextElementSibling;el.classList.toggle('open');a.classList.toggle('open');} // GIS MAP const PARISH_COORDS={Kingston:[17.9784,-76.7827],'St. Andrew':[18.0747,-76.7489],'St. Thomas':[17.95,-76.55],Portland:[18.18,-76.45],'St. Mary':[18.30,-76.90],'St. Ann':[18.42,-77.20],Trelawny:[18.47,-77.63],'St. James':[18.47,-77.92],Hanover:[18.42,-78.13],Westmoreland:[18.20,-78.17],'St. Elizabeth':[18.05,-77.75],Manchester:[18.05,-77.50],Clarendon:[17.95,-77.25],'St. Catherine':[17.98,-77.00]}; const MAP_PINS={ farms:[{name:'Rose Hill Farm',lat:18.06,lng:-77.51,info:'Manchester ยท Carrot, Escallion, Pumpkin'},{name:'Clarendon Agro Co-op',lat:17.97,lng:-77.23,info:'Clarendon ยท Tomato, Cucumber, Dasheen'},{name:'St. Elizabeth Veg Farm',lat:18.04,lng:-77.76,info:'St. Elizabeth ยท Carrot, Pumpkin, Cabbage'},{name:'Portland Green Farms',lat:18.18,lng:-76.46,info:'Portland ยท Cabbage, Plantain, Pak Choi'},{name:'Trelawny Root Crop Co.',lat:18.48,lng:-77.62,info:'Trelawny ยท Yam, Sweet Potato, Coco'}], agroparks:[{name:'Ebony Park Agro Park',lat:17.85,lng:-77.20,info:'Clarendon ยท 1,197 acres ยท Active'},{name:'Spring Plain Agro Park',lat:17.86,lng:-77.21,info:'Clarendon ยท 944 acres ยท Active'},{name:'New Forest Agro Park',lat:18.05,lng:-77.50,info:'Manchester ยท 2,400 acres ยท Active'},{name:'Amity Hall (SPAD)',lat:17.99,lng:-77.05,info:'St. Catherine ยท 1,150 acres ยท In Development'},{name:'Parnassus (SPAD)',lat:17.92,lng:-77.15,info:'Clarendon ยท 756 acres ยท In Development'}], markets:[{name:'Coronation Market',lat:17.998,lng:-76.797,info:'Kingston ยท Open daily'},{name:'Linstead Market',lat:18.133,lng:-76.983,info:'St. Catherine ยท Saturdays'},{name:'Montego Bay Market',lat:18.476,lng:-77.917,info:'St. James ยท Mon-Sat'},{name:'Mandeville Market',lat:18.042,lng:-77.503,info:'Manchester ยท Daily'}], cold:[{name:'Caribbean Cold Storage',lat:17.998,lng:-76.796,info:'Kingston ยท 500 tonnes'},{name:'South Coast Cold Hub',lat:18.05,lng:-77.76,info:'St. Elizabeth ยท 200 tonnes'}], labor:[{name:'Manchester Labor Zone',lat:18.05,lng:-77.52,info:'8 workers needed ยท Carrot harvest'},{name:'Clarendon Labor Zone',lat:17.97,lng:-77.24,info:'12 workers needed ยท Tomato picking'}], export:[{name:'Kingston Port (KGN)',lat:17.975,lng:-76.787,info:'Main cargo port'},{name:'Sangster Airport (MBJ)',lat:18.504,lng:-77.914,info:'Air cargo ยท High-value produce'}], research:[{name:'Bodles Research Station',lat:17.958,lng:-77.052,info:'St. Catherine ยท Main R&D Centre'},{name:'Orange River Station',lat:18.27,lng:-76.97,info:'St. Mary ยท Crop Trials'},{name:'Montpelier Station',lat:18.45,lng:-77.87,info:'St. James ยท Livestock R&D'}], }; const layerColors={farms:'#16A34A',agroparks:'#059669',markets:'#F59E0B',cold:'#0891B2',labor:'#7C3AED',export:'#DC2626',research:'#8B5CF6'}; let activeLayers={farms:true}; let leafletPins={farms:[],agroparks:[],markets:[],cold:[],labor:[],export:[],research:[]}; function initMap(){if(mapInstance)return;var mapDiv=document.getElementById('ja-map');if(!mapDiv)return;mapInstance=L.map('ja-map').setView([18.11,-77.30],9);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution:'ยฉ OpenStreetMap',maxZoom:18}).addTo(mapInstance);Object.keys(PARISH_COORDS).forEach(p=>{const c=PARISH_COORDS[p];const items=DATA.filter(d=>d.parish===p),avg=items.length?Math.round(items.reduce((a,b)=>a+b.most_frequent,0)/items.length):0;var _pm=L.circleMarker(c,{radius:7,fillColor:'#1E40AF',color:'white',weight:2,fillOpacity:.8});_pm.bindPopup('\uD83D\uDCCD '+p+'
Avg: J$'+avg+'/kg
'+items.length+' commodities');_pm.addTo(mapInstance);});addMapLayer('farms');} function addMapLayer(type){if(!mapInstance)return;const pins=MAP_PINS[type]||[];const color=layerColors[type]||'#555';leafletPins[type]=pins.map(p=>{const m=L.circleMarker([p.lat,p.lng],{radius:10,fillColor:color,color:'white',weight:2,fillOpacity:.9});m.bindPopup(`${p.name}
${p.info}`);m.addTo(mapInstance);return m;});} function removeMapLayer(type){(leafletPins[type]||[]).forEach(m=>mapInstance.removeLayer(m));leafletPins[type]=[];} function toggleLayer(type){activeLayers[type]=!activeLayers[type];document.getElementById('layer-'+type).classList.toggle('active',activeLayers[type]);if(activeLayers[type])addMapLayer(type);else removeMapLayer(type);} // SHARING function shareEmail(){window.open(`mailto:?subject=HelloAG Jamaica Market Watch May 2026&body=Jamaica agricultural market prices and insights: ${window.location.href}`);} function shareWhatsApp(){window.open(`https://wa.me/?text=${encodeURIComponent('๐Ÿ‡ฏ๐Ÿ‡ฒ Jamaica Market Watch โ€” Week of May 3, 2026. HelloAG: '+window.location.href)}`);} function shareFacebook(){window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(window.location.href)}`);} function shareTwitter(){window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent('๐Ÿ‡ฏ๐Ÿ‡ฒ Jamaica Market Watch May 2026')}&url=${encodeURIComponent(window.location.href)}`);} function copyLink(){navigator.clipboard.writeText(window.location.href).then(()=>toast('๐Ÿ”— Link copied!')).catch(()=>{});} // MODALS function openModal(id){document.getElementById('modal-'+id)?.classList.add('open');} function closeModal(id){document.getElementById('modal-'+id)?.classList.remove('open');} document.querySelectorAll('.modal-overlay').forEach(o=>o.addEventListener('click',function(e){if(e.target===this)this.classList.remove('open');})); function submitForm(type){closeModal(type);const msgs={subscribe:'โœ… Welcome to HelloAG! Check your WhatsApp soon.',register:'โœ… Registered! You\'ll appear in the directory within 24 hours.',labor:'โœ… Listing posted!'};toast(msgs[type]||'โœ… Done!');} // CALCULATOR function switchCalc(n){[1,2,3].forEach(i=>{document.getElementById('ct'+i)?.classList.toggle('active',i===n);document.getElementById(i===1?'calc-unit':i===2?'calc-revenue':'calc-markup').style.display=i===n?'block':'none';});} function calcUnit(){const v=parseFloat(document.getElementById('inp-kg').value)||0;document.getElementById('inp-lb').value=(v*2.2046).toFixed(2);const r=document.getElementById('unit-result');if(v){r.style.display='block';r.textContent=`${v} kg = ${(v*2.2046).toFixed(2)} lbs`;}} function calcUnitRev(){const v=parseFloat(document.getElementById('inp-lb').value)||0;document.getElementById('inp-kg').value=(v/2.2046).toFixed(2);const r=document.getElementById('unit-result');if(v){r.style.display='block';r.textContent=`${v} lbs = ${(v/2.2046).toFixed(2)} kg`;}} function calcRevenue(){const p=parseFloat(document.getElementById('r-price').value)||0,q=parseFloat(document.getElementById('r-qty').value)||0,t=parseFloat(document.getElementById('r-transport').value)||0;const g=p*q,n=g-t,r=document.getElementById('rev-result');if(p&&q){r.style.display='block';r.innerHTML=`Gross: J$${g.toLocaleString()}
Net (after transport): J$${n.toLocaleString()}
Net per kg: J$${(n/q).toFixed(0)}`;}} function calcMarkup(){const f=parseFloat(document.getElementById('m-farm').value)||0,s=parseFloat(document.getElementById('m-sell').value)||0,d=s-f,pct=f?((d/f)*100).toFixed(1):0,r=document.getElementById('markup-result');if(f&&s){r.style.display='block';r.innerHTML=`Margin: J$${d.toFixed(0)}/kg
Markup: ${pct}%
${pct>100?'โœ… Good margin':'โš ๏ธ Review your costs'}`;}} // TOAST function toast(msg){const t=document.getElementById('toast');t.textContent=msg;t.classList.add('show');setTimeout(()=>t.classList.remove('show'),2800);} // TAB SWITCH const TAB_ORDER=['dashboard','prices','heatmap','alerts','export','agroparks','gismap','labor','govt','research','mechanization','education','directory','videos','news','whatsapp','faq','subscribe']; function switchTab(id){document.querySelectorAll('.tab').forEach(p=>p.classList.remove('active'));document.querySelectorAll('.nav-btn').forEach(b=>b.classList.remove('active'));document.getElementById('tab-'+id)?.classList.add('active');const nb=document.querySelectorAll('.nav-btn');const idx=TAB_ORDER.indexOf(id);if(idx>=0&&nb[idx])nb[idx].classList.add('active');if(id==='gismap')setTimeout(initMap,100);window.scrollTo({top:0,behavior:'smooth'});} // โ•โ• SUBSCRIBE & SHARE FUNCTIONS โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• function submitSubscribe() { var name = document.querySelector('#modal-subscribe .m-inp[type="text"]'); var phone = document.querySelector('#modal-subscribe .m-inp[type="tel"]'); var email = document.querySelector('#modal-subscribe .m-inp[type="email"]'); var tier = document.querySelector('#modal-subscribe select') ; var nameVal = name ? name.value.trim() : ''; var phoneVal = phone ? phone.value.trim() : ''; var emailVal = email ? email.value.trim() : ''; if (!nameVal || !phoneVal) { showToast('Please enter your name and WhatsApp number'); return; } // Build WhatsApp message to HelloAG registration number var msg = 'HelloAG Registration%0AName: ' + encodeURIComponent(nameVal) + '%0AWhatsApp: ' + encodeURIComponent(phoneVal) + (emailVal ? '%0AEmail: ' + encodeURIComponent(emailVal) : '') + '%0ATier: Free'; window.open('https://wa.me/18765551234?text=' + msg, '_blank'); showToast('Redirecting to WhatsApp registrationโ€ฆ'); closeModal('subscribe'); } function copyCard(idx) { var cards = document.querySelectorAll('.wa-body'); if (cards[idx]) { var text = cards[idx].textContent || ''; if (navigator.clipboard) { navigator.clipboard.writeText(text).then(function() { showToast('Card copied to clipboard โœ“'); }); } else { var ta = document.createElement('textarea'); ta.value = text; document.body.appendChild(ta); ta.select(); document.execCommand('copy'); document.body.removeChild(ta); showToast('Card copied โœ“'); } } } function shareWA(text) { window.open('https://wa.me/?text=' + encodeURIComponent(text), '_blank'); } function shareFB() { window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(window.location.href), '_blank'); } function shareTW(text) { window.open('https://twitter.com/intent/tweet?text=' + encodeURIComponent(text || 'Check out HelloAG Jamaica market intelligence'), '_blank'); } function printPage() { window.print(); } // โ•โ• INIT โ•โ• // 1) Render immediately with fallback data โ€” visitors never see a blank page buildTicker(); buildKPIs(); buildBestVal(); buildTopScarce(); buildParishOv(); buildBarChart(); buildParishFilter(); renderTable(DATA); renderHeatmap(); buildAlerts(); buildExport(); buildAgroParkGrid(); renderGovt(); buildResearch(); buildTractors(); buildSchools(); filterDir(); buildLabor(); filterVideos(); buildWhatsApp(); buildFAQ(); applyWeekLabel(); setDataStatus('fallback', 'Loadingโ€ฆ'); // 2) Fetch live data in background and refresh if successful loadFromGoogleSheets().then(function(liveData) { if (liveData && liveData.length > 0) { rebuildDashboard(liveData); applyWeekLabel(); } });