From 00c0641f06a8f875164a0fef57afba2e737b0ea5 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 27 Apr 2015 10:16:47 -0400 Subject: [PATCH] Make view extent include both local and remote versions of the change --- js/id/renderer/map.js | 13 +++++++++---- js/id/ui/conflicts.js | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index f7cf27792..ed6dd2841 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -409,10 +409,15 @@ iD.Map = function(context) { } }; - map.trimmedExtent = function() { - var headerY = 60, footerY = 30, pad = 10; - return new iD.geo.Extent(projection.invert([pad, dimensions[1] - footerY - pad]), - projection.invert([dimensions[0] - pad, headerY + pad])); + map.trimmedExtent = function(_) { + if (!arguments.length) { + var headerY = 60, footerY = 30, pad = 10; + return new iD.geo.Extent(projection.invert([pad, dimensions[1] - footerY - pad]), + projection.invert([dimensions[0] - pad, headerY + pad])); + } else { + var extent = iD.geo.Extent(_); + map.centerZoom(extent.center(), map.trimmedExtentZoom(extent)); + } }; function calcZoom(extent, dim) { diff --git a/js/id/ui/conflicts.js b/js/id/ui/conflicts.js index 321dd9a0b..01ef1e76c 100644 --- a/js/id/ui/conflicts.js +++ b/js/id/ui/conflicts.js @@ -198,17 +198,27 @@ iD.ui.Conflicts = function(context) { .selectAll('input') .property('checked', function(d) { return d === datum; }); + var extent = iD.geo.Extent(), + entity; + + entity = context.graph().hasEntity(datum.id); + if (entity) extent._extend(entity.extent(context.graph())); + datum.action(); - zoomToEntity(datum.id); + + entity = context.graph().hasEntity(datum.id); + if (entity) extent._extend(entity.extent(context.graph())); + + zoomToEntity(datum.id, extent); } - function zoomToEntity(id) { + function zoomToEntity(id, extent) { context.surface().selectAll('.hover') .classed('hover', false); var entity = context.graph().hasEntity(id); if (entity) { - context.map().zoomTo(entity); + context.map().trimmedExtent(extent); context.surface().selectAll( iD.util.entityOrMemberSelector([entity.id], context.graph())) .classed('hover', true);