mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-02 05:01:38 +02:00
Enable zoom-to-center of multiple selected entities (close #6696)
This commit is contained in:
@@ -69,6 +69,12 @@ export function modeSelect(context, selectedIDs) {
|
||||
}
|
||||
}
|
||||
|
||||
function selectedEntities() {
|
||||
return selectedIDs.map(function(id) {
|
||||
return context.hasEntity(id);
|
||||
}).filter(Boolean);
|
||||
}
|
||||
|
||||
|
||||
function checkSelectedIDs() {
|
||||
var ids = [];
|
||||
@@ -192,10 +198,7 @@ export function modeSelect(context, selectedIDs) {
|
||||
|
||||
|
||||
mode.zoomToSelected = function() {
|
||||
var entity = singular();
|
||||
if (entity) {
|
||||
context.map().zoomToEase(entity);
|
||||
}
|
||||
context.map().zoomToEase(selectedEntities());
|
||||
};
|
||||
|
||||
|
||||
|
||||
+14
-2
@@ -854,8 +854,20 @@ export function rendererMap(context) {
|
||||
};
|
||||
|
||||
|
||||
map.zoomToEase = function(entity, duration) {
|
||||
var extent = entity.extent(context.graph());
|
||||
map.zoomToEase = function(obj, duration) {
|
||||
var extent;
|
||||
if (Array.isArray(obj)) {
|
||||
obj.forEach(function(entity) {
|
||||
var entityExtent = entity.extent(context.graph());
|
||||
if (!extent) {
|
||||
extent = entityExtent;
|
||||
} else {
|
||||
extent = extent.extend(entityExtent);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
extent = obj.extent(context.graph());
|
||||
}
|
||||
if (!isFinite(extent.area())) return map;
|
||||
|
||||
var z2 = clamp(map.trimmedExtentZoom(extent), 0, 20);
|
||||
|
||||
Reference in New Issue
Block a user