From 63690c141cee9bf1f329ce4c1efeaa8ee40dba10 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Tue, 27 Nov 2012 14:17:30 -0500 Subject: [PATCH] Fix one-way textPath breakage, webkit... --- NOTES.md | 3 +++ js/iD/renderer/Map.js | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/NOTES.md b/NOTES.md index 54467790e..bd65ad544 100644 --- a/NOTES.md +++ b/NOTES.md @@ -22,6 +22,9 @@ Way drawing strategy: * END: Click on self-segment * END: Escape key +* [Adding a new road in MapZen](http://www.youtube.com/watch?v=tdpDm6MiUEM) +* [Editing turn restrictions](http://www.youtube.com/watch?v=DyHorSJFbyg) + ## Pathological conditions * Ways with one node diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index 027677e0f..9ccf27989 100644 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -227,12 +227,12 @@ iD.Map = function(elem, connection) { .classed('active', classActive); // Determine the lengths of oneway paths - var lengths = []; + var lengths = {}; var oneways = strokes .filter(function(d, i) { return d.tags.oneway && d.tags.oneway === 'yes'; }).each(function(d, i) { - lengths.push(Math.floor(this.getTotalLength() / alength / 4)); + lengths[d.id] = Math.floor(this.getTotalLength() / alength); }).data(); var uses = defs.selectAll('path') @@ -240,20 +240,23 @@ iD.Map = function(elem, connection) { uses.exit().remove(); uses.enter().append('path'); uses - .attr('id', function(d, i) { return 'shadow-' + i; }) + .attr('id', function(d, i) { return 'shadow-' + d.id; }) .attr('d', function(d) { return d._line; }); var labels = text_g.selectAll('text') .data(oneways, key); labels.exit().remove(); var tp = labels.enter() - .append('text') - .attr({ 'class': 'oneway', dy: 4 }) - .append('textPath'); - tp.attr('letter-spacing', alength * 4) - .attr('xlink:href', function(d, i) { return '#shadow-' + i; }) + .append('text').attr({ 'class': 'oneway', dy: 4 }) + .append('textPath').attr('class', 'textpath'); + // why not just selectAll('textPath')? + // https://bugs.webkit.org/show_bug.cgi?id=46800 + // https://bugs.webkit.org/show_bug.cgi?id=83438 + text_g.selectAll('.textpath') + .attr('letter-spacing', alength * 2) + .attr('xlink:href', function(d, i) { return '#shadow-' + d.id; }) .text(function(d, i) { - return (new Array(lengths[i])).join('►'); + return (new Array(Math.floor(lengths[d.id] / 2))).join('►'); }); }