[WIP] attempting to add task outline gpxLayer to map_in_map

This commit is contained in:
Brad Parker
2015-06-13 12:15:57 +10:00
parent 7e28947f66
commit 304ac66c5f
2 changed files with 39 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1">
<metadata>
<link href="https://github.com/hotosm/osm-tasking-manager2">
<text>HOT Tasking Manager</text>
</link>
<time>2015-06-13T01:58:26.967102</time>
</metadata>
<trk>
<name>Task for project 1062</name>
<trkseg>
<trkpt lon="85.8361816252" lat="27.702983731"></trkpt>
<trkpt lon="85.8471679534" lat="27.702983731"></trkpt>
<trkpt lon="85.8471679534" lat="27.7127102563"></trkpt>
<trkpt lon="85.8361816252" lat="27.7127102563"></trkpt>
<trkpt lon="85.8361816252" lat="27.702983731"></trkpt>
</trkseg>
</trk>
</gpx>
+19 -1
View File
@@ -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')