-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
157 lines (139 loc) · 4.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Get Lat+Lon with Squares</title>
<script src="Squares-D3-demo.min.js"></script>
<link rel="stylesheet" href="http://www.openstreetmap.us/~migurski/style.css" />
<style title="text/css">
<!--
#map
{
border-top: 1px solid black;
border-bottom: 1px solid black;
width: 100%;
height: 420px;
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
}
#map-center
{
z-index: 99;
position: absolute;
top: 50%;
left: 50%;
}
#map-center img,
#map-center #vertical-rule,
#map-center #horizontal-rule
{
position: absolute;
pointer-events: none;
}
#map-center img
{
top: -8px;
left: -8px;
}
#map-center #vertical-rule
{
border-left: 1px solid rgba(0, 0, 0, .1);
height: 420px;
top: -210px;
}
#map-center #horizontal-rule
{
border-top: 1px solid rgba(0, 0, 0, .1);
width: 1350px;
left: -675px;
}
img.tile,
div.tile
{
display: block;
position: absolute;
margin: 0;
padding: 0;
border: 0;
-webkit-transform-origin: 0px 0px;
}
#info1
{
float: left;
}
#info1, #info2
{
width: 20em;
}
-->
</style>
</head>
<body>
<h1>Get Lat+Lon</h1>
<div id="map">
<div id="map-center">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARAQMAAAABo9W5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRFAAAA////pdmf3QAAAAJ0Uk5T/wDltzBKAAAAEklEQVQI12P4X9/AgA+DAAE1AEQwH+EzObtuAAAAAElFTkSuQmCC">
<div id="vertical-rule"> </div>
<div id="horizontal-rule"> </div>
</div>
</div>
<pre id="info1"></pre>
<pre id="info2"></pre>
<p>
Find geographic coordinates for any place on earth, in degrees latitude
and longitude, spherical mercator meters, and web slippy map tiles.
Built with <a href="https://github.com/migurski/Squares#readme">Squares</a>,
a small, extensible, free and open-source library for in-browser maps,
written in Typescript and using D3 under the hood.
</p>
<p>
Map tiles courtesy of <a href="http://maps.stamen.com">Stamen</a>.
</p>
<p>
I miss getlatlon.com.
</p>
<script type="application/javascript">
<!--
var info1 = document.getElementById('info1'),
info2 = document.getElementById('info2');
function update_info(map)
{
var zoom = map.grid.zoom(),
digits = Math.round(Math.log(1 << zoom + 8) / Math.log(10)),
latlon_digits = Math.max(0, digits - 2),
mercator_digits = Math.max(0, digits - 7),
round = (Math.round(zoom) == zoom),
merc = new sq.Geo.Mercator(),
loc = map.pointLocation(),
lat = loc.lat.toFixed(latlon_digits),
lon = loc.lon.toFixed(latlon_digits),
point = merc.project(loc),
x = (6378137 * point.x).toFixed(mercator_digits),
y = (6378137 * point.y).toFixed(mercator_digits),
coord = merc.locationCoordinate(loc).zoomTo(Math.round(zoom)).container(),
tile = [coord.zoom, coord.column, coord.row].join('/'),
lines = [
'Lat, lon: ' + [lat, lon].join(', '),
'Mercator: ' + [x, y].join(', '),
' Zoom: ' + zoom.toFixed(0) + (round ? '' : ' (' + zoom.toFixed(2) + ')'),
' Tile: <a href="http://tile.openstreetmap.org/' + tile + '.png" target="_blank">' + tile + '</a>',
' WKT’s: POINT (' + [lon, lat].join(' ') + ')',
' POINT (' + [x, y].join(' ') + ')',
]
info1.innerHTML = lines.slice(0, 3).join('\n');
info2.innerHTML = lines.slice(3, 6).join('\n');
}
/*
var map = sq.makeDivMap(document.getElementById('map'), 37.804319, -122.271210, 12);
*/
var map = sq.makeImgMap(document.getElementById('map'),
'http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png',
37.804319, -122.271210, 12);
map.onMoved(update_info);
update_info(map);
//-->
</script>
</body>
</html>