From 1e5e588ae69126f056a9d5a0e55d27df4ceaae9b Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 11 Jan 2013 07:19:49 -0800 Subject: [PATCH] Clean up --- js/id/renderer/map.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index ac61ce5ae..86bcf67b8 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -15,13 +15,13 @@ iD.Map = function() { background = iD.Background() .projection(projection), transformProp = iD.util.prefixCSSProperty('Transform'), - supersurface, surface, defs, tilegroup, r, g; + surface, tilegroup; - function map() { - tilegroup = this.append('div') + function map(selection) { + tilegroup = selection.append('div') .attr('id', 'tile-g'); - supersurface = this.append('div') + var supersurface = selection.append('div') .style('position', 'absolute') .call(zoom); @@ -34,21 +34,23 @@ iD.Map = function() { } }); - defs = surface.append('defs'); - defs.append('clipPath') + surface.append('defs') + .append('clipPath') .attr('id', 'clip') .append('rect') .attr('id', 'clip-rect') .attr({ x: 0, y: 0 }); - r = surface.append('g') + var clip = surface.append('g') .attr('clip-path', 'url(#clip)'); - g = ['fill', 'casing', 'stroke', 'text', 'hit', 'temp'].reduce(function(mem, i) { - return (mem[i] = r.append('g').attr('class', 'layer-g layer-' + i)) && mem; - }, {}); + var layers = clip.selectAll('.layer') + .data(['fill', 'casing', 'stroke', 'text', 'hit']) - map.size(this.size()); + layers.enter().append('g') + .attr('class', function(d) { return 'class', 'layer layer-' + d; }); + + map.size(selection.size()); map.surface = surface; d3.select(document).call(keybinding); @@ -98,7 +100,7 @@ iD.Map = function() { } function editOff() { - surface.selectAll('.layer-g *').remove(); + surface.selectAll('.layer *').remove(); } function connectionLoad(err, result) {