Sky Map Now body { font-family: Arial, sans-serif; max-width: 600px; margin: 20px auto; text-align: center; } select { padding: 10px; margin: 10px; font-size: 16px; width: 200px; max-height: 200px; } #results { margin-top: 45px; } .case { margin-bottom: 10px; } #timeDisplay { font-size: 20px; margin-top: 20px; line-height: 1.5; } .error { color: red; } https://cdn.plot.ly/plotly-latest.min.js

Sky Map Now for Sun, Moon and 5 Planets

Please select a city near you to see Sky Map Now.
Select a City Anchorage Bangkok Cairo Calcutta Chicago Denver Hong Kong Honolulu London Los Angeles Mexico City Moscow New York Paris Rome Saigon Shanghai Singapore Taipei Tampa Tokyo
https://cdn.jsdelivr.net/npm/suncalc@1.9.0/suncalc.min.js let centerDot = { x: [], //0,-72,-64,-67,-51,-19,-60,-53], y: [], //0, -22,6.4,-56,-73,66,30,-76], mode: ‘markers+text’, name: ‘Center’, marker: { size: 7, color: ‘red’ }, text: [‘北極星(Polaris)’,’日(Sun)’,’月(Moon)’,’水星(Me)’,’金星(V)’,’火星(Ma)’,’木星(J)’,’土星(S)’], textposition: ‘right’, textfont: { size: 12 } }; let dd=0.; let xec=0; let yec=0; let zec=0; let sunRA=0; let longi=0; let daylightSave=1; let solarHA=0; let lati=0; let year1=0; let month1=0; let day1=0; let hours1=0; let minutes1=0; let seconds1=0; let cityName=””; const degRad=180 / Math.PI; // const xYear=year2; // const xMonth=month2; // const xDay=day2; // const xHH=hours2; //UTC time // const xMM=minutes2; // const xSS=seconds2; function getJulianDay(date) { const year = date.getUTCFullYear(); const month = date.getUTCMonth() + 1; const day = date.getUTCDate(); const hour = date.getUTCHours(); const minute = date.getUTCMinutes(); const second = date.getUTCSeconds(); let a = Math.floor((14 – month) / 12); let y = year + 4800 – a; let m = month + 12 * a – 3; let jd = day + Math.floor((153 * m + 2) / 5) + 365 * y + Math.floor(y / 4) – Math.floor(y / 100) + Math.floor(y / 400) – 32045; jd += (hour – 12 + minute / 60 + second / 3600) / 24; return jd.toFixed(6); } function getSolarNoon() { const citySelect = document.getElementById(‘citySelect’); const timeDisplay = document.getElementById(‘timeDisplay’); const city = citySelect.value; cityName=city; // Check if SunCalc is loaded if (typeof SunCalc === ‘undefined’) { timeDisplay.innerHTML = ‘Error: SunCalc library failed to load.‘; return; } if (!city) { timeDisplay.textContent = ‘Please select a city to see Sky Map Now.’; return; } // City coordinates and time zone data const cities = { ‘Anchorage’: { lat: 61.2181, lon: -149.9003, tz: ‘America/Anchorage’ }, ‘Bangkok’: { lat: 13.7563, lon: 100.5018, tz: ‘Asia/Bangkok’ }, ‘Cairo’: { lat: 30.0444, lon: 31.2357, tz: ‘Africa/Cairo’ }, ‘Calcutta’: { lat: 22.5726, lon: 88.3639, tz: ‘Asia/Kolkata’ }, ‘Chicago’: { lat: 41.8781, lon: -87.6298, tz: ‘America/Chicago’ }, ‘Denver’: { lat: 39.7392, lon: -104.9903, tz: ‘America/Denver’ }, ‘Hong Kong’: { lat: 22.3193, lon: 114.1694, tz: ‘Asia/Hong_Kong’ }, ‘Honolulu’: { lat: 21.3069, lon: -157.8583, tz: ‘Pacific/Honolulu’ }, ‘London’: { lat: 51.5074, lon: -0.1278, tz: ‘Europe/London’ }, ‘Los Angeles’: { lat: 34.0522, lon: -118.2437, tz: ‘America/Los_Angeles’ }, ‘Mexico City’: { lat: 19.4326, lon: -99.1332, tz: ‘America/Mexico_City’ }, ‘Moscow’: { lat: 55.7558, lon: 37.6173, tz: ‘Europe/Moscow’ }, ‘New York’: { lat: 40.7128, lon: -74.0060, tz: ‘America/New_York’ }, ‘Paris’: { lat: 48.8566, lon: 2.3522, tz: ‘Europe/Paris’ }, ‘Rome’: { lat: 41.9028, lon: 12.4964, tz: ‘Europe/Rome’ }, ‘Saigon’: { lat: 10.7769, lon: 106.7009, tz: ‘Asia/Ho_Chi_Minh’ }, ‘Shanghai’: { lat: 31.2304, lon: 121.4737, tz: ‘Asia/Shanghai’ }, ‘Singapore’: { lat: 1.3521, lon: 103.8198, tz: ‘Asia/Singapore’ }, ‘Taipei’: { lat: 25.0330, lon: 121.5654, tz: ‘Asia/Taipei’ }, ‘Tampa’: { lat: 27.9506, lon: -82.4572, tz: ‘America/New_York’ }, ‘Tokyo’: { lat: 35.6762, lon: 139.6503, tz: ‘Asia/Tokyo’ } }; const { lat, lon, tz } = cities[city]; lati=lat; // Get current date and time in the city’s time zone and UTC const now = new Date(); const options = { timeZone: tz, year: ‘numeric’, month: ‘short’, day: ‘numeric’, hour: ‘2-digit’, minute: ‘2-digit’, second: ‘2-digit’, hour12: false }; const currentDateTime = new Intl.DateTimeFormat(‘en-US’, options).format(now); const utcOptions = { timeZone: ‘UTC’, year: ‘numeric’, month: ‘short’, day: ‘numeric’, hour: ‘2-digit’, minute: ‘2-digit’, second: ‘2-digit’, hour12: false }; const utcDateTime = new Intl.DateTimeFormat(‘en-US’, utcOptions).format(now); // Calculate Julian Day const julianDay = getJulianDay(now); dd=julianDay-2451543.5; try { // Calculate solar noon using SunCalc const times = SunCalc.getTimes(now, lat, lon); const solarNoon = times.solarNoon; if (!solarNoon) { throw new Error(‘Solar noon calculation failed.’); } // Format solar noon time in the city’s time zone const solarNoonTime = new Intl.DateTimeFormat(‘en-US’, options).format(solarNoon); // timeDisplay.innerHTML = `Current Date and Time in ${city}: ${currentDateTime}
Solar Noon in ${city}: ${solarNoonTime}
UTC Date and Time: ${utcDateTime} (UTC)
Julian Day: ${julianDay}`; const parts_c = currentDateTime.split(‘,’); const [cHH, cMM,cSS] = parts_c[2].split(‘:’); //.map(Number); const parts_s = solarNoonTime.split(‘,’); const dateStr=parts_c[0]+”,”+parts_c[1]; const date1=new Date(dateStr); const [sHH, sMM,sSS] = parts_s[2].split(‘:’); solarHA=(cHH-sHH+(cMM-sMM)/60+(cSS-sSS)/3600)*15; year1=date1.getFullYear(); month1=date1.getMonth()+1; day1=date1.getDate(); hours1=cHH; minutes1=cMM; seconds1=cSS; // document.getElementById(“demo5”).innerHTML =”dd= “+dd.toFixed(2)+” current hh=” +cHH+” “+cMM+” “+sHH+” “+sMM+” HA=”+solarHA.toFixed(2); // document.getElementById(“demo2″).innerHTML =”yr1, month1 etc=”+year1+” “+month1+” “+day1+” “+hours1+” “+minutes1+” “+seconds1; // Date(currentDateTime).getHours(); } catch (error) { timeDisplay.innerHTML = `Current Date and Time in ${city}: ${currentDateTime} (${tz})
Error calculating solar noon: ${error.message}
UTC Date and Time: ${utcDateTime} (UTC)
Julian Day: ${julianDay}`; } startCalculation(); } function startCalculation() { // The five cases of side lengths const cases = [ [282.9404,4.71E-05,1,0.016709,-1.151E-09,356.047,0.985600259,23.4393,-3.563E-07,0,0,0,0], [318.0634,0.164357322,60.2666,0.0549,0,115.3654,13.06499295,23.4393,-3.563E-07,5.1454,0,125.1228,-0.052953808], [29.1241,1.01E-05,0.387098,0.205635,5.59E-10,168.6562,4.092334437,23.4393,-3.563E-07,7.0047,0.00000005,48.3313,3.24587E-05], [54.891,1.38E-05,0.72333,0.006773,-1.302E-09,48.0052,1.602130224,23.4393,-3.563E-07,3.3946,2.75E-08,76.6799,0.000024659], [286.53736,2.0094E-05,1.523688,0.093405,1.26796E-09,18.6021,0.524020777,23.4393,-3.563E-07,1.84988,-2.191E-07,49.562,-0.000008004], [273.8777,1.6451E-05,5.20256,0.048498,4.469E-09,19.895,0.0830853,23.4393,-3.563E-07,1.303,-1.557E-07,100.4542,2.76854E-05], [339.3939,2.9766E-05,9.55475,0.055546,-9.499E-09,316.967,0.033444228,23.4393,-3.563E-07,2.4886,-1.081E-07,113.6634,0.000023898] ]; const outputDiv = document.getElementById(“results”); outputDiv.innerHTML = “”; centerDot.x[0]=0; centerDot.y[0]=0; cases.forEach((params, index) => { const [w0,w1,a,e0,e1,M0,M1,ob0,ob1,i0,i1,N0,N1] = params; const result = calculateRAAndDEC(w0,w1,a,e0,e1,M0,M1,ob0,ob1,i0,i1,N0,N1); const xplusy=calculateXY(result.RA, result.DEC); // document.getElementById(“demo2″).innerHTML =”In start cal:” +index+” ;x= “+xplusy.x; centerDot.x[index+1]=xplusy.x; centerDot.y[index+1]=xplusy.y; outputDiv.innerHTML += `
`; }); xDraw(); } function calculateRAAndDEC(w0,w1,a,e0,e1,M0,M1,ob0,ob1,i0,i1,N0,N1) { //const dd=9251.5; const w=w0+w1*dd; const e=e0+e1*dd; const M=(M0+M1*dd)%360; const ob=ob0+ob1*dd; const i=i0+i1*dd; const N=N0+N1*dd; const L=(w+M)%360; const E=degRad*(M/degRad+e*Math.sin(M/degRad)*(1+e*Math.cos(M/degRad))); const x=a*(Math.cos(E/degRad)-e); const y=a*(Math.sin(E/degRad)*Math.sqrt(1-e*e)); const r=Math.sqrt(x*x+y*y); const v=Math.atan2(y,x)*degRad; const Long=(v+w)%360; const x_eclip=r*(Math.cos(N/degRad)*Math.cos((v+w)/degRad)-Math.sin(N/degRad)*Math.sin((v+w)/degRad)*Math.cos(i/degRad)); const y_eclip=r*(Math.sin(N/degRad)*Math.cos((v+w)/degRad)+Math.cos(N/degRad)*Math.sin((v+w)/degRad)*Math.cos(i/degRad)); const z_eclip=r*Math.sin((v+w)/degRad)*Math.sin(i/degRad); const hEc_Lon=Math.atan2(y_eclip,x_eclip)*degRad+360; const hEc_Lat=Math.atan2(z_eclip,Math.sqrt(x_eclip*x_eclip+y_eclip*y_eclip))*degRad; const x_geoc=x_eclip+xec; const y_geoc=y_eclip+yec; const z_geoc=z_eclip+zec; const xequat=x_geoc; const yequat=y_geoc*Math.cos(ob/degRad)-z_geoc*Math.sin(ob/degRad); const zequat=y_geoc*Math.sin(ob/degRad)+z_geoc*Math.cos(ob/degRad); const rdr=Math.sqrt(xequat*xequat+yequat*yequat+zequat*zequat); const RA=Math.atan2(yequat,xequat)*degRad; const DEC=Math.atan2(zequat, Math.sqrt(xequat*xequat+yequat*yequat))*degRad; if (a==1) {xec=x_eclip; yec=y_eclip; sunRA=RA;} // document.getElementById(“demo4″).innerHTML =”In Calc RA DEC:” +RA+”, “+DEC; return { RA, DEC }; } // Function 5 to calculate x and y ******************************* function calculateXY(RA,DEC) { // document.getElementById(“demo3″).innerHTML =”In Cal_XY:”; // +wrdx; //EOT // const JD=2460795; //const tau=(JD-2451545)/365250; //const Lo=(280.4664567+360007.6982779*tau+0.03032028*tau**2+tau**3/49931-tau**4/15300-tau**5/2000000)%360; // const EOT=4*(Lo-sunRA%360); // Hour Angle of observer and the Sun. // const solarHH=13; xHH=8; xMM=3; offsetUTC=-4; //12+daylightSave; //const longi15=longi/15; //const solarMM=5; // -EOT-4*15*(longi15 – Math.floor(longi15)); //const solarHA=((xHH+offsetUTC)-solarHH+(xMM-solarMM)/60)*15; const sunOffset=270+solarHA+sunRA; // document.getElementById(“demo4″).innerHTML =”In end of Cal_XY: SolarHA=” +solarHA+”,sunOffset= “+sunOffset; // +wrdx; const x=(90-DEC)*Math.cos((-RA+sunOffset)/degRad); const y=(90-DEC)*Math.sin((-RA+sunOffset)/degRad); return { x, y}; } // Function **************************************** function xDraw() { const xVals = []; const yVals = []; let rho=0; // for declaration of variables using let. let d90=90; //const lati=cityLat; // latitude of NYC is 40.7 // document.getElementById(“demo3”).innerHTML =”In xDraw, lati=”+lati; const circleRad=180-lati; const degToRad = Math.PI / 180; const radToDeg = 180 / Math.PI; const tan40 = Math.tan(lati * degToRad); // tan(40.7°) for (let phiDeg =0; phiDeg <= 360; phiDeg += 3) { const phiRad = phiDeg * degToRad; const sinPhi = Math.sin(phiRad); if (Math.abs(sinPhi) < 1e-6) { d90=90; if (phiDeg == 180) {d90=-90;} xVals.push(d90); yVals.push(0); continue; } else { const tanRho = tan40 / sinPhi; rho = Math.atan(tanRho); // in radians if (rho < 0) {rho += Math.PI;} const x = rho * radToDeg * Math.cos(phiRad); const y = rho * radToDeg * Math.sin(phiRad); xVals.push(x); yVals.push(y); } } const data = { x: xVals, y: yVals, mode: 'lines', type: 'scatter', marker: { color: 'blue' }, name: 'x vs y' }; const theta = []; const x_circle = []; const y_circle = []; const radius = circleRad; for (let i = 0; i <= 360; i++) { theta.push(i * Math.PI / 180); x_circle.push(radius * Math.cos(theta[i])); y_circle.push(radius * Math.sin(theta[i])); } // Circle trace const circle = { x: x_circle, y: y_circle, mode: 'lines', name: 'Circle', line: { color: 'blue' } }; // Center dot and label // Layout const layout = { xaxis: { range: [-185, 185], zeroline: true, scaleanchor: 'y', // keep the aspect ratio square scaleratio: 1 }, yaxis: { range: [-160, 160], zeroline: true }, annotations: [ { x: -130, y: -50, text: '東(E)', showarrow: false, xanchor: 'left', yanchor: 'top', font: { size: 14 } }, { x: 105, y: -50, text: '西(W)', showarrow: false, xanchor: 'left', yanchor: 'top', font: { size: 14 } }, { x: -12, y: 43, text: '北(N)', showarrow: false, xanchor: 'left', yanchor: 'top', font: { size: 14 } } ], width: 700, height: 700, // '° ' title: 'Sky Map for 七曜及北極星 ('+cityName+ ', local time ' +month1+'/'+day1+'/'+year1+' '+hours1 +':' +minutes1+':' +seconds1+')', showlegend: false }; Plotly.newPlot('plot', [data, circle, centerDot], layout); // document.getElementById("demo1").innerHTML ="x[1]= "+centerDot.x[1]; // +wrdx; }