Skip to content

Instantly share code, notes, and snippets.

@blaurt
blaurt / composer.json
Created February 11, 2019 10:18 — forked from andyshinn/composer.json
Docker Compose PHP Composer Example
{
"require": {
"mfacenet/hello-world": "v1.*"
}
}
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);
@blaurt
blaurt / main.css
Last active April 20, 2020 06:46
styles for coords conversion example
header {
text-align: center;
}
section {
text-align: center;
}
section .map {
display: inline-block;
@blaurt
blaurt / index.html
Last active April 20, 2020 06:45
Html structure for coord conversion example
<!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>
@blaurt
blaurt / coords.js
Created April 20, 2020 06:54
coords snippet
// New York
const latitudeNY = 41.145556;
const longitudeNY = -73.995;
// Melbourne
const latitudeML = -37.867579;
const longitudeML = 145.048621;
@blaurt
blaurt / mapContainer.js
Created April 20, 2020 06:55
map & pointer containers
const pointersContainer = document.querySelector("#pointers-container");
const mapImage = document.querySelector(".map img");
const mapWidth = mapImage.clientWidth;
const mapHeight = mapImage.clientHeight;
@blaurt
blaurt / renderPointer.js
Created April 20, 2020 06:55
renderPointer.js
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);
}
@blaurt
blaurt / latLonToOffsets.js
Last active March 28, 2022 17:30
transformAndPoint.js
/**
* @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);
@blaurt
blaurt / degreesToRadians.js
Created April 21, 2020 05:58
degreesToRadians.js
/**
* @param {number} degrees
*/
function degreesToRadians(degrees) {
return (degrees * Math.PI) / 180;
}
@blaurt
blaurt / callingConvertion.js
Created April 21, 2020 06:25
calling convertion function and render results
[
{ lat: latitudeNY, lon: longitudeNY },
{ lat: latitudeML, lon: longitudeML }
].forEach(({ lat, lon }) => {
const { x, y } = latLonToOffsets(lat, lon, mapWidth, mapHeight);
renderPointer(x, y);
});