diff --git a/js/id/renderer/gpx_layer.js b/js/id/renderer/gpx_layer.js index 379557a76..f44c38d94 100644 --- a/js/id/renderer/gpx_layer.js +++ b/js/id/renderer/gpx_layer.js @@ -22,9 +22,12 @@ iD.GpxLayer = function(context, dispatch) { .append('path') .attr('class', 'gpx'); + var path = d3.geo.path() + .projection(projection); + paths - .attr('d', d3.geo.path().projection(projection)); - + .attr('d', path); + if (typeof gj.features !== 'undefined') { svg .selectAll('text') @@ -33,21 +36,19 @@ iD.GpxLayer = function(context, dispatch) { svg .selectAll('path') .data(gj.features) - .enter() + .enter() .append('text') .attr('class', 'gpx') .text(function(d) { return d.properties.name; }) .attr('x', function(d) { - var centroid = d3.geo.path().projection(projection) - .centroid(d); - return centroid[0] + 5; + var centroid = path.centroid(d); + return centroid[0] + 5; }) .attr('y', function(d) { - var centroid = d3.geo.path().projection(projection) - .centroid(d); - return centroid[1]; + var centroid = path.centroid(d); + return centroid[1]; }); } }