mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 23:44:47 +02:00
Fix zooming to validated features. Fixes #748
This commit is contained in:
@@ -180,7 +180,7 @@ iD.modes.Select = function(context, selection, initial) {
|
||||
if (showMenu) context.surface().call(radialMenu);
|
||||
|
||||
context.surface()
|
||||
.on('dblclick.select', dblclick)
|
||||
.on('dblclick.select', dblclick);
|
||||
}, 200);
|
||||
};
|
||||
|
||||
|
||||
+16
-12
@@ -308,21 +308,25 @@ iD.Map = function(context) {
|
||||
return new iD.geo.Extent(projection.invert([0, dimensions[1]]),
|
||||
projection.invert([dimensions[0], 0]));
|
||||
} else {
|
||||
var extent = iD.geo.Extent(_),
|
||||
tl = projection([extent[0][0], extent[1][1]]),
|
||||
br = projection([extent[1][0], extent[0][1]]);
|
||||
|
||||
// Calculate maximum zoom that fits extent
|
||||
var hFactor = (br[0] - tl[0]) / dimensions[0],
|
||||
vFactor = (br[1] - tl[1]) / dimensions[1],
|
||||
hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2,
|
||||
vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2,
|
||||
newZoom = map.zoom() - Math.max(hZoomDiff, vZoomDiff);
|
||||
|
||||
map.centerZoom(extent.center(), newZoom);
|
||||
map.centerZoom(extent.center(), map.extentZoom(extent));
|
||||
}
|
||||
};
|
||||
|
||||
map.extentZoom = function(_) {
|
||||
var extent = iD.geo.Extent(_),
|
||||
tl = projection([extent[0][0], extent[1][1]]),
|
||||
br = projection([extent[1][0], extent[0][1]]);
|
||||
|
||||
// Calculate maximum zoom that fits extent
|
||||
var hFactor = (br[0] - tl[0]) / dimensions[0],
|
||||
vFactor = (br[1] - tl[1]) / dimensions[1],
|
||||
hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2,
|
||||
vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2,
|
||||
newZoom = map.zoom() - Math.max(hZoomDiff, vZoomDiff);
|
||||
|
||||
return newZoom;
|
||||
};
|
||||
|
||||
map.flush = function() {
|
||||
context.connection().flush();
|
||||
context.history().reset();
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ iD.ui.Save = function(context) {
|
||||
if (!history.hasChanges()) return;
|
||||
|
||||
connection.authenticate(function(err) {
|
||||
var modal = iD.ui.modal(context.container());
|
||||
modal = iD.ui.modal(context.container());
|
||||
var changes = history.changes();
|
||||
changes.connection = connection;
|
||||
modal.select('.content')
|
||||
@@ -67,8 +67,8 @@ iD.ui.Save = function(context) {
|
||||
}
|
||||
|
||||
function clickFix(d) {
|
||||
map.extent(d.entity.extent(context.graph()));
|
||||
if (map.zoom() > 19) map.zoom(19);
|
||||
var extent = d.entity.extent(context.graph());
|
||||
map.centerZoom(extent.center(), Math.min(19, map.extentZoom(extent)));
|
||||
context.enter(iD.modes.Select(context, [d.entity.id]));
|
||||
modal.remove();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user