Skip to content
This repository was archived by the owner on Jan 8, 2021. It is now read-only.

Commit 3c265d0

Browse files
committed
Merge pull request #305 from mitjap/issue#215
Added OpenStreetMap layer to map (#215)
2 parents adb066e + 5db8d1d commit 3c265d0

File tree

1 file changed

+34
-13
lines changed
  • piplmesh/panels/map/static/piplmesh/panel/map

1 file changed

+34
-13
lines changed
Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
11
$(document).ready(function () {
22
var nodeLocation = new google.maps.LatLng(node.latitude, node.longitude);
3+
34
var myOptions = {
4-
zoom: 15,
5-
center: nodeLocation,
6-
scrollwheel: false,
7-
navigationControl: false,
8-
scaleControl: false,
9-
draggable: false,
10-
mapTypeId: google.maps.MapTypeId.ROADMAP,
11-
streetViewControl: false
5+
'zoom': 15,
6+
'center': nodeLocation,
7+
'scrollwheel': false,
8+
'navigationControl': false,
9+
'scaleControl': false,
10+
'draggable': false,
11+
// TODO: allow user to set default layer
12+
'mapTypeId': google.maps.MapTypeId.ROADMAP,
13+
'mapTypeControlOptions': {
14+
'mapTypeIds': [
15+
'OpenStreetMap',
16+
google.maps.MapTypeId.ROADMAP,
17+
google.maps.MapTypeId.SATELLITE
18+
]
19+
},
20+
'streetViewControl': false
1221
};
22+
1323
var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
24+
25+
map.mapTypes.set('OpenStreetMap', new google.maps.ImageMapType({
26+
getTileUrl: function(coordinates, zoom) {
27+
return 'http://tile.openstreetmap.org/' + zoom + '/' + coordinates.x + '/' + coordinates.y + '.png';
28+
},
29+
'tileSize': new google.maps.Size(256, 256),
30+
'name': 'OpenStreetMap',
31+
'maxZoom': 18
32+
}));
33+
34+
var marker = new google.maps.Marker({
35+
'position': nodeLocation,
36+
'map': map,
37+
'title': node.name
38+
});
39+
1440
var nodeName = $('<p/>').text(node.name).append(' | ');
1541
var nodeWebsite = $('<a/>').prop('href', node.url).text(gettext("more info"));
1642
nodeName.append(nodeWebsite);
1743
$('#map_info').append(nodeName);
18-
var marker = new google.maps.Marker({
19-
position: nodeLocation,
20-
map: map,
21-
title: node.name
22-
});
2344
});

0 commit comments

Comments
 (0)