https://github.com/rossengeorgiev/nite-overlay
🌍 Nightime overlay with all twilight zones for Google Maps API 3
https://github.com/rossengeorgiev/nite-overlay
google-maps-api javascript night overlay
Last synced: 3 months ago
JSON representation
🌍 Nightime overlay with all twilight zones for Google Maps API 3
- Host: GitHub
- URL: https://github.com/rossengeorgiev/nite-overlay
- Owner: rossengeorgiev
- License: other
- Created: 2013-01-23T23:04:50.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-04-28T22:55:50.000Z (about 2 years ago)
- Last Synced: 2025-03-20T15:03:21.580Z (3 months ago)
- Topics: google-maps-api, javascript, night, overlay
- Language: JavaScript
- Homepage:
- Size: 240 KB
- Stars: 80
- Watchers: 7
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Nite Overlay - Overview
Generates an overlay to illustrate the day/night cycle.
There are 4 shade levels going from light to dark.
They are civil twilight, nautical twilight, astronomical twilight and night.Works with Google Maps API v3
The sun position is estimated using an adapted method from NOAA's solar calculator, which is based on equations from Astronomical Algorithms, by Jean Meeus.
More details: https://gml.noaa.gov/grad/solcalc/calcdetails.html*Might not work on some mobile devices. I've not explored the reason for this*
## Quick start
```javascript
var map = google.maps.Map(...);
nite.init(map);
```
Use `refresh()` method to update the overlay periodically. Perhaps via `setInterval()`;```
setInterval(function() { nite.refresh() }, 10000); // every 10s
```Alternatively, a specific date can be selected via `setDate()` followed by a call to `refresh()` to redraw the overlay. Setting the date to `null` will cause nite overlay to use current date and time.
Note: *If the overlay is hidden and refresh() is called, the overlay position will not be updated.
Not until the overlay is visible again.*## Available methods
`nite.setMap()` set a specific map object
`nite.setDate(Date object)` set a specific datetime, or `null` to use current datetime
`nite.calculatePositionOfSun(Date object)` returns LatLng for the specified date (has no effect on the overlay)
`nite.refresh()` Recalculate and refresh the position of the overlay
`nite.isVisible()` returns a boolean if the overlay is visible on the map
`nite.show()` Make the overlay visible
`nite.hide()` Hide the overlay
`nite.getSunPosition()` returns LatLng for the Sun
`nite.getShadowPosition()` returns LatLng for the night side