From 304ac66c5fcc92c2567d904593d12bb2bba38aea Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 13 Jun 2015 12:15:57 +1000 Subject: [PATCH] [WIP] attempting to add task outline gpxLayer to map_in_map --- data/123.gpx | 20 ++++++++++++++++++++ js/id/ui/map_in_map.js | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 data/123.gpx diff --git a/data/123.gpx b/data/123.gpx new file mode 100644 index 000000000..7e378a633 --- /dev/null +++ b/data/123.gpx @@ -0,0 +1,20 @@ + + + + + + HOT Tasking Manager + + + + + Task for project 1062 + + + + + + + + + diff --git a/js/id/ui/map_in_map.js b/js/id/ui/map_in_map.js index 385807854..0c7d18917 100644 --- a/js/id/ui/map_in_map.js +++ b/js/id/ui/map_in_map.js @@ -3,6 +3,8 @@ iD.ui.MapInMap = function(context) { function map_in_map(selection) { var backgroundLayer = iD.TileLayer(), + gpxLayer = iD.GpxLayer(context) + .projection(context.projection), overlayLayer = iD.TileLayer(), projection = iD.geo.RawMercator(), zoom = d3.behavior.zoom() @@ -134,7 +136,6 @@ iD.ui.MapInMap = function(context) { .append('div') .attr('class', 'map-in-map-tiles'); - // redraw background backgroundLayer .source(context.background().baseLayerSource()) @@ -152,6 +153,10 @@ iD.ui.MapInMap = function(context) { background .call(backgroundLayer); + // Add the gpxLayer _somewhere_ here + // background + // .call(gpxLayer) + // redraw overlay var overlaySources = context.background().overlayLayerSources(), hasOverlay = false; @@ -261,6 +266,19 @@ iD.ui.MapInMap = function(context) { if (drawn.full === true) redraw(); }); + function toDom(x) { + return (new DOMParser()).parseFromString(x, 'text/xml'); + } + + var q = iD.util.stringQs(location.hash.substring(1)); + var gpx = q.gpx; + if (gpx) { + d3.text(gpx, function(err, gpxTxt) { + gpxLayer.geojson(toGeoJSON.gpx(toDom(gpxTxt))); + console.log(gpxTxt) + queueRedraw(); + }); + } redraw(); var keybinding = d3.keybinding('map-in-map')