Skip to content

Commit de53595

Browse files
added OSM base tile sets, #41
The following sets are included: * OSM standard * OSM black and white * OSM Stamen.com watecolor * OSM Stamen.com toner
1 parent e4bfedd commit de53595

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

js/tracker.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,31 @@ function update_lookangles(idx) {
149149

150150
var range_string = (look.range < 10000) ? Math.round(look.range) + "m" : (Math.round(look.range/100)/10) + " km";
151151
$("#lookanglesbox .range").text(range_string);
152+
}
152153

154+
// map type list
155+
var maptypes = {
156+
osm: ['OSM','OpenStreetMaps.org', function(xy,z) { return 'http://a.tile.openstreetmap.org/'+z+'/'+xy.x+'/'+xy.y+'.png'; }],
157+
osm_toner: ['OSM Toner','Stamen.org Toner', function(xy,z) { return 'http://a.tile.stamen.com/toner/'+z+'/'+xy.x+'/'+xy.y+'.png'; }],
158+
osm_watercolor: ['OSM Watercolor','Stamen.org Watercolor', function(xy,z) { return 'http://c.tile.stamen.com/watercolor/'+z+'/'+xy.x+'/'+xy.y+'.png'; }],
159+
osm_bw: ['OSM B&W','OSM Black & White', function(xy,z) { return 'http://a.www.toolserver.org/tiles/bw-mapnik/'+z+'/'+xy.x+'/'+xy.y+'.png'; }],
153160
}
154161

162+
// generate a list of names for the UI
163+
var maptype_ids = ["roadmap","satellite","terrain"]
164+
for(var i in maptypes) maptype_ids.push(i);
165+
166+
155167
function load() {
156168
//initialize map object
157169
map = new google.maps.Map(document.getElementById('map'), {
158170
zoom: 5,
159171
center: new google.maps.LatLng(53.467511,-2.2338940),
160172
mapTypeId: google.maps.MapTypeId.ROADMAP,
173+
mapTypeControlOptions: {
174+
mapTypeIds: maptype_ids,
175+
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
176+
},
161177
keyboardShortcuts: false,
162178
streetViewControl: false,
163179
rotateControl: false,
@@ -169,7 +185,17 @@ function load() {
169185
},
170186
scrollwheel: true
171187
});
188+
// register custom map types
189+
for(var i in maptypes) {
190+
map.mapTypes.set(i, new google.maps.ImageMapType({
191+
getTileUrl: maptypes[i][2],
192+
tileSize: new google.maps.Size(256, 256),
193+
maxZoom: 18,
194+
name: maptypes[i][0]
195+
}));
196+
}
172197

198+
// update current position if we geolocation is available
173199
if(currentPosition) updateCurrentPosition(currentPosition.lat, currentPosition.lon);
174200

175201
// initalize nite overlay

0 commit comments

Comments
 (0)