From a1e47746f4f454d82c2cd954314fbdadf3b26d6e Mon Sep 17 00:00:00 2001 From: mitjap Date: Tue, 25 Sep 2012 00:52:44 +0200 Subject: [PATCH 1/4] Added OpenStreetMap layer to map (#215) --- .../map/static/piplmesh/panel/map/panel.js | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js index 157398d3..47af12bf 100644 --- a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js +++ b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js @@ -1,5 +1,7 @@ $(document).ready(function () { + var element = document.getElementById('map_canvas'); var nodeLocation = new google.maps.LatLng(node.latitude, node.longitude); + var myOptions = { zoom: 15, center: nodeLocation, @@ -7,17 +9,37 @@ $(document).ready(function () { navigationControl: false, scaleControl: false, draggable: false, - mapTypeId: google.maps.MapTypeId.ROADMAP, + mapTypeId: "OSM", + mapTypeControlOptions: { + mapTypeIds: [ + "OSM", + google.maps.MapTypeId.ROADMAP, + google.maps.MapTypeId.SATELLITE + ] + }, streetViewControl: false }; - var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); - var nodeName = $('

').text(node.name).append(' | '); - var nodeWebsite = $('').prop('href', node.url).text(gettext("more info")); - nodeName.append(nodeWebsite); - $('#map_info').append(nodeName); + + var map = new google.maps.Map(element, myOptions); + + map.mapTypes.set("OSM", new google.maps.ImageMapType({ + getTileUrl: function(coord, zoom) { + return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; + }, + tileSize: new google.maps.Size(256, 256), + name: "OpenStreetMap", + maxZoom: 18 + })); + var marker = new google.maps.Marker({ position: nodeLocation, map: map, title: node.name }); + + var nodeName = $('

').text(node.name).append(' | '); + var nodeWebsite = $('').prop('href', node.url).text(gettext("more info")); + nodeName.append(nodeWebsite); + $('#map_info').append(nodeName); + }); From cb848b252c09898bbd9de0be369451d32f86f433 Mon Sep 17 00:00:00 2001 From: mitjap Date: Tue, 25 Sep 2012 14:18:23 +0200 Subject: [PATCH 2/4] Minor changes on map panel (javascript changes) --- .../map/static/piplmesh/panel/map/panel.js | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js index 47af12bf..44d3951e 100644 --- a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js +++ b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js @@ -1,45 +1,43 @@ $(document).ready(function () { - var element = document.getElementById('map_canvas'); var nodeLocation = new google.maps.LatLng(node.latitude, node.longitude); var myOptions = { - zoom: 15, - center: nodeLocation, - scrollwheel: false, - navigationControl: false, - scaleControl: false, - draggable: false, - mapTypeId: "OSM", - mapTypeControlOptions: { - mapTypeIds: [ - "OSM", + 'zoom': 15, + 'center': nodeLocation, + 'scrollwheel': false, + 'navigationControl': false, + 'scaleControl': false, + 'draggable': false, + 'mapTypeId': 'OpenStreetMap', + 'mapTypeControlOptions': { + 'mapTypeIds': [ + 'OpenStreetMap', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE ] }, - streetViewControl: false + 'streetViewControl': false }; - var map = new google.maps.Map(element, myOptions); + var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); - map.mapTypes.set("OSM", new google.maps.ImageMapType({ - getTileUrl: function(coord, zoom) { - return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; + map.mapTypes.set('OpenStreetMap', new google.maps.ImageMapType({ + getTileUrl: function(coordinates, zoom) { + return 'http://tile.openstreetmap.org/' + zoom + '/' + coordinates.x + '/' + coordinates.y + '.png'; }, - tileSize: new google.maps.Size(256, 256), - name: "OpenStreetMap", - maxZoom: 18 + 'tileSize': new google.maps.Size(256, 256), + 'name': 'OpenStreetMap', + 'maxZoom': 18 })); var marker = new google.maps.Marker({ - position: nodeLocation, - map: map, - title: node.name + 'position': nodeLocation, + 'map': map, + 'title': node.name }); var nodeName = $('

').text(node.name).append(' | '); - var nodeWebsite = $('').prop('href', node.url).text(gettext("more info")); + var nodeWebsite = $('').prop('href', node.url).text(gettext('more info')); nodeName.append(nodeWebsite); $('#map_info').append(nodeName); - }); From d1e920b8ba4d81700aa7b0c117e5cb7f92eb0600 Mon Sep 17 00:00:00 2001 From: mitjap Date: Thu, 27 Sep 2012 05:12:34 +0300 Subject: [PATCH 3/4] Update piplmesh/panels/map/static/piplmesh/panel/map/panel.js issue #215 - Fixed quotes --- piplmesh/panels/map/static/piplmesh/panel/map/panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js index 44d3951e..56ad46ad 100644 --- a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js +++ b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js @@ -37,7 +37,7 @@ $(document).ready(function () { }); var nodeName = $('

').text(node.name).append(' | '); - var nodeWebsite = $('').prop('href', node.url).text(gettext('more info')); + var nodeWebsite = $('').prop('href', node.url).text(gettext("more info")); nodeName.append(nodeWebsite); $('#map_info').append(nodeName); }); From 5db8d1d6e6cc578ae79158ba738f6ba6dc6f4571 Mon Sep 17 00:00:00 2001 From: mitjap Date: Thu, 27 Sep 2012 05:15:38 +0300 Subject: [PATCH 4/4] Update piplmesh/panels/map/static/piplmesh/panel/map/panel.js issue #215 - set default layer to roadmap --- piplmesh/panels/map/static/piplmesh/panel/map/panel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js index 56ad46ad..1bf5d0d2 100644 --- a/piplmesh/panels/map/static/piplmesh/panel/map/panel.js +++ b/piplmesh/panels/map/static/piplmesh/panel/map/panel.js @@ -8,7 +8,8 @@ $(document).ready(function () { 'navigationControl': false, 'scaleControl': false, 'draggable': false, - 'mapTypeId': 'OpenStreetMap', + // TODO: allow user to set default layer + 'mapTypeId': google.maps.MapTypeId.ROADMAP, 'mapTypeControlOptions': { 'mapTypeIds': [ 'OpenStreetMap',