Skip to content

Commit

Permalink
Add Google Maps to Suncalc.org
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleplus committed Apr 17, 2024
1 parent 2090117 commit 3e972f5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions javascripts/Google Maps to SunCalc.org.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use strict";
var coordinates;
var pieces = location.href.split('/');
for (let i = 0; i < pieces.length; i++) {
if (pieces[i].startsWith('@')) {
coordinates = pieces[i].substring(1);
break;
}
}
if (typeof coordinates === 'undefined') {
window.alert('Current Google Maps URL does not contain coordinates.');
} else {
const now = new Date();
location.href = 'https://www.suncalc.org/#/' + coordinates + '/' + now.getFullYear() + '.' + (now.getMonth() + 1) + '.' + now.getDate() + '/' + now.getHours() ':' + now.getMinutes() + '/1/3';
}

0 comments on commit 3e972f5

Please sign in to comment.