Skip to content

Commit db8fac7

Browse files
upp nite-overlay to v1.7
1 parent 0a2d732 commit db8fac7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

js/nite-overlay.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Nite v1.5
1+
/* Nite v1.7
22
* A tiny library to create a night overlay over the map
33
* Author: Rossen Georgiev @ https://github.com/rossengeorgiev
44
* Requires: GMaps API 3
@@ -25,7 +25,7 @@ var nite = {
2525
this.marker_twilight_civil = new google.maps.Circle({
2626
map: this.map,
2727
center: this.getShadowPosition(),
28-
radius: this.getShadowRadiusFromAngle(0),
28+
radius: this.getShadowRadiusFromAngle(0.566666),
2929
fillColor: "#000",
3030
fillOpacity: 0.1,
3131
strokeOpacity: 0,
@@ -92,7 +92,7 @@ var nite = {
9292
var rad = 0.017453292519943295;
9393

9494
// based on NOAA solar calculations
95-
var mins_past_midnight = (date.getUTCHours() * 60 + date.getUTCMinutes()) / 1440;
95+
var ms_past_midnight = ((date.getUTCHours() * 60 + date.getUTCMinutes()) * 60 + date.getUTCSeconds()) * 1000 + date.getUTCMilliseconds();
9696
var jc = (this.jday(date) - 2451545)/36525;
9797
var mean_long_sun = (280.46646+jc*(36000.76983+jc*0.0003032)) % 360;
9898
var mean_anom_sun = 357.52911+jc*(35999.05029-0.0001537*jc);
@@ -107,8 +107,9 @@ var nite = {
107107
var eccent = 0.016708634-jc*(0.000042037+0.0000001267*jc);
108108
var y = Math.tan(rad*(obliq_corr/2))*Math.tan(rad*(obliq_corr/2));
109109
var rq_of_time = 4*((y*Math.sin(2*rad*mean_long_sun)-2*eccent*Math.sin(rad*mean_anom_sun)+4*eccent*y*Math.sin(rad*mean_anom_sun)*Math.cos(2*rad*mean_long_sun)-0.5*y*y*Math.sin(4*rad*mean_long_sun)-1.25*eccent*eccent*Math.sin(2*rad*mean_anom_sun))/rad);
110-
var true_solar_time = (mins_past_midnight*1440+rq_of_time) % 1440;
111-
var lng = -((true_solar_time/4 < 0) ? true_solar_time/4 + 180 : true_solar_time/4 - 180);
110+
var true_solar_time_in_deg = ((ms_past_midnight+rq_of_time*60000) % 86400000) / 240000;
111+
112+
var lng = -((true_solar_time_in_deg < 0) ? true_solar_time_in_deg + 180 : true_solar_time_in_deg - 180);
112113

113114
return new google.maps.LatLng(lat, lng);
114115
},

0 commit comments

Comments
 (0)