This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"mfacenet/hello-world": "v1.*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const x = (longitude + 180) * (mapWidth / 360); | |
const latRad = (latitude * Math.PI) / 180; | |
const mercN = Math.log(Math.tan(Math.PI / 4 + latRad / 2)); | |
const y = mapHeight / 2 - (mapWidth * mercN) / (2 * Math.PI); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header { | |
text-align: center; | |
} | |
section { | |
text-align: center; | |
} | |
section .map { | |
display: inline-block; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Map app</title> | |
<link rel="shortcut icon" href="images/favicon.png" type="image/x-icon" /> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// New York | |
const latitudeNY = 41.145556; | |
const longitudeNY = -73.995; | |
// Melbourne | |
const latitudeML = -37.867579; | |
const longitudeML = 145.048621; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pointersContainer = document.querySelector("#pointers-container"); | |
const mapImage = document.querySelector(".map img"); | |
const mapWidth = mapImage.clientWidth; | |
const mapHeight = mapImage.clientHeight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function renderPointer(x, y) { | |
const pointer = document.createElement("span"); | |
pointer.classList.add("pointer"); | |
pointer.style.left = `${x}px`; | |
pointer.style.top = `${y}px`; | |
pointersContainer.appendChild(pointer); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number} latitude in degrees | |
* @param {number} longitude in degrees | |
* @param {number} mapWidth in pixels | |
* @param {number} mapHeight in pixels | |
*/ | |
function latLonToOffsets(latitude, longitude, mapWidth, mapHeight) { | |
const FE = 180; // false easting | |
const radius = mapWidth / (2 * Math.PI); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number} degrees | |
*/ | |
function degreesToRadians(degrees) { | |
return (degrees * Math.PI) / 180; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ lat: latitudeNY, lon: longitudeNY }, | |
{ lat: latitudeML, lon: longitudeML } | |
].forEach(({ lat, lon }) => { | |
const { x, y } = latLonToOffsets(lat, lon, mapWidth, mapHeight); | |
renderPointer(x, y); | |
}); |
OlderNewer