-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
167 lines (153 loc) · 5.63 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
158
159
160
161
162
163
164
165
166
167
<html><head>
<meta name="viewport" content="width=device-width">
<style type="text/css">
@media only screen and (min-device-width : 480px) and (max-device-width : 800px) {
#moveto {
visibility: hidden;
display: none;
}
}
</style>
</head><body>
<!-- This file is based on http://sandbox.freemap.sk/dynamic_poi/
That site is CC-BY-SA 2.0. If you are looking for examples to follow,
try that URL.
To the extend appropriate under US Law:
(c) 2013-2014 Trever L. Adams
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. -->
<div id="moveto">
<form>
Latitude: <input type="number" id="i_lat" size="10">
Longitude: <input type="number" id="i_lon" size="10">
Grid-Square: <input type="text" id="i_grid" size="4">
<button onclick="forcePosition(); return false;">Move Map</button>
</form>
<script type="text/javascript">
// This is a simple translation of a function found at:
// http://en.wikipedia.org/wiki/Maidenhead_Locator_System
// (c) 2012 Chris Ruvolo. Licensed under a 2-clause BSD license.
function grid2latlon(grid)
{
var lon = (grid.charCodeAt(0) - 'A'.charCodeAt(0)) * 20 - 180;
var lat = (grid.charCodeAt(1) - 'A'.charCodeAt(0)) * 10 - 90;
lon += (grid.charCodeAt(2) - '0'.charCodeAt(0)) * 2;
lat += (grid.charCodeAt(3) - '0'.charCodeAt(0)) * 1;
if (grid.length >= 5) {
lon += (grid.charCodeAt(4) - 'a'.charCodeAt(0)) * 5/60;
lat += (grid.charCodeAt(5) - 'a'.charCodeAt(0)) * 2.5/60;
// move to center of subsquare
lon += 2.5/60;
lat += 1.25/60;
} else {
// Move to center of square
lon += 1;
lat += 0.5;
}
return {
lon: lon,
lat: lat
};
}
function forcePosition()
{
var lat = this.document.getElementById("i_lat").value
var lon = this.document.getElementById("i_lon").value
var gs = this.document.getElementById("i_grid").value
if(lon != "" && lat != "")
{
this.lat = lat;
this.lon = lon;
}
else if(gs != null)
{
var data = grid2latlon(gs);
this.lat = data.lat;
this.lon = data.lon;
}
setRealCenter();
return false;
}
</script>
</div>
<div id="mapdiv"></div>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript" src="MarkerGrid.js"></script>
<script type="text/javascript" src="MarkerTile.js"></script>
<script type="text/javascript" src="bounds.js"></script>
<script type="text/javascript">
var lat=38.4667;
var lon=-30;
// Default Zoom
var zoom=17;
// Any zoom level below this will not show access points
var minimum_zoom_display=0;
// Any zoom level above this will not be pruned
var maximum_zoom_prune=-1;
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(setPosition, errorPos);
}
function setPosition(position)
{
this.lat = position.coords.latitude;
this.lon = position.coords.longitude;
setTimeout(setRealCenter, 10);
}
function errorPos(err) {
};
function get_poi_url (bounds) {
//bounds = this.adjustBounds(bounds);
var res = this.map.getResolution();
var z = this.map.getZoom();
var path = "l=" + getLeft(bounds)
+ "&t=" + getTop(bounds)
+ "&r=" + getRight(bounds)
+ "&b=" + getBottom(bounds)
+ "&z=" + z
+ "&res=" + res
+ "&mzd=" + minimum_zoom_display
+ "&mzp=" + maximum_zoom_prune
var url = "http://web_server_fqdn/path_to_owmpdv/get_local_ap.php?";
return url + path;
}
function setRealCenter() {
//Set start centrepoint and zoom
var lonLat = new OpenLayers.LonLat( lon, lat)
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
map.setCenter (lonLat, this.zoom);
}
map = new OpenLayers.Map("mapdiv", {units: "ft", projection: new OpenLayers.Projection("EPSG:900913"), displayProjection: new OpenLayers.Projection("EPSG:4326")});
maplayer = new OpenLayers.Layer.OSM();
// create POI layer
POI = new OpenLayers.Layer.MarkerGrid( "POI",
{
type:'txt',
getURL: get_poi_url,
attribution: "Open WLAN Map",
buffer: 0
});
POI.setIsBaseLayer(false);
POI.setVisibility(true);
map.addLayers([maplayer,POI]);
//Set start centrepoint and zoom
var lonLat = new OpenLayers.LonLat( -30, 38.4667 )
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
map.setCenter (lonLat, zoom);
setTimeout(setRealCenter, 10);
</script>
</body></html>