mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Remove map convenience functions of context
This commit is contained in:
@@ -152,7 +152,7 @@ export function behaviorDraw(context) {
|
||||
d3_event.preventDefault();
|
||||
d3_event.stopPropagation();
|
||||
|
||||
var currSpace = context.mouse();
|
||||
var currSpace = context.map().mouse();
|
||||
if (_disableSpace && _lastSpace) {
|
||||
var dist = geoVecLength(_lastSpace, currSpace);
|
||||
if (dist > tolerance) {
|
||||
|
||||
@@ -129,7 +129,7 @@ export function behaviorDrawWay(context, wayID, index, mode, startGraph) {
|
||||
loc = targetLoc;
|
||||
|
||||
} else if (targetNodes) { // snap to way - a line target with `.nodes`
|
||||
var choice = geoChooseEdge(targetNodes, context.mouse(), context.projection, _drawNode.id);
|
||||
var choice = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, _drawNode.id);
|
||||
if (choice) {
|
||||
loc = choice.loc;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export function behaviorLasso(context) {
|
||||
context.surface().call(lasso);
|
||||
}
|
||||
|
||||
lasso.p(context.mouse());
|
||||
lasso.p(context.map().mouse());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export function behaviorPaste(context) {
|
||||
d3_event.preventDefault();
|
||||
|
||||
var baseGraph = context.graph();
|
||||
var mouse = context.mouse();
|
||||
var mouse = context.map().mouse();
|
||||
var projection = context.projection;
|
||||
var viewport = geoExtent(projection.clipExtent()).polygon();
|
||||
|
||||
|
||||
@@ -512,14 +512,6 @@ export function coreContext() {
|
||||
}
|
||||
|
||||
_map = rendererMap(context);
|
||||
context.mouse = _map.mouse;
|
||||
context.extent = _map.extent;
|
||||
context.pan = _map.pan;
|
||||
context.zoomIn = _map.zoomIn;
|
||||
context.zoomOut = _map.zoomOut;
|
||||
context.zoomInFurther = _map.zoomInFurther;
|
||||
context.zoomOutFurther = _map.zoomOutFurther;
|
||||
context.redrawEnable = _map.redrawEnable;
|
||||
|
||||
Object.values(services).forEach(service => {
|
||||
if (service && typeof service.init === 'function') {
|
||||
|
||||
@@ -549,7 +549,7 @@ export function coreHistory(context) {
|
||||
|
||||
if (missing.length && osm) {
|
||||
loadComplete = false;
|
||||
context.redrawEnable(false);
|
||||
context.map().redrawEnable(false);
|
||||
|
||||
var loading = uiLoading(context).blocking(true);
|
||||
context.container().call(loading);
|
||||
@@ -576,7 +576,7 @@ export function coreHistory(context) {
|
||||
|
||||
if (err || !missing.length) {
|
||||
loading.close();
|
||||
context.redrawEnable(true);
|
||||
context.map().redrawEnable(true);
|
||||
dispatch.call('change');
|
||||
dispatch.call('restore', this);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export function modeAddNote(context) {
|
||||
osm.replaceNote(note);
|
||||
|
||||
// force a reraw (there is no history change that would otherwise do this)
|
||||
context.pan([0,0]);
|
||||
context.map().pan([0,0]);
|
||||
|
||||
context
|
||||
.selectedNoteID(note.id)
|
||||
|
||||
@@ -51,7 +51,7 @@ export function modeDragNode(context) {
|
||||
function startNudge(entity, nudge) {
|
||||
if (_nudgeInterval) window.clearInterval(_nudgeInterval);
|
||||
_nudgeInterval = window.setInterval(function() {
|
||||
context.pan(nudge);
|
||||
context.map().pan(nudge);
|
||||
doMove(entity, nudge);
|
||||
}, 50);
|
||||
}
|
||||
@@ -207,7 +207,7 @@ export function modeDragNode(context) {
|
||||
}
|
||||
|
||||
} else if (targetNodes) { // snap to way - a line target with `.nodes`
|
||||
edge = geoChooseEdge(targetNodes, context.mouse(), context.projection, end.id);
|
||||
edge = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, end.id);
|
||||
if (edge) {
|
||||
loc = edge.loc;
|
||||
}
|
||||
@@ -379,7 +379,7 @@ export function modeDragNode(context) {
|
||||
);
|
||||
|
||||
} else if (target && target.type === 'way') {
|
||||
var choice = geoChooseEdge(context.graph().childNodes(target), context.mouse(), context.projection, entity.id);
|
||||
var choice = geoChooseEdge(context.graph().childNodes(target), context.map().mouse(), context.projection, entity.id);
|
||||
context.replace(
|
||||
actionAddMidpoint({
|
||||
loc: choice.loc,
|
||||
|
||||
@@ -27,7 +27,7 @@ export function modeDragNote(context) {
|
||||
function startNudge(nudge) {
|
||||
if (_nudgeInterval) window.clearInterval(_nudgeInterval);
|
||||
_nudgeInterval = window.setInterval(function() {
|
||||
context.pan(nudge);
|
||||
context.map().pan(nudge);
|
||||
doMove(nudge);
|
||||
}, 50);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export function modeMove(context, entityIDs, baseGraph) {
|
||||
fn = context.overwrite;
|
||||
}
|
||||
|
||||
var currMouse = context.mouse();
|
||||
var currMouse = context.map().mouse();
|
||||
var origMouse = context.projection(_origin);
|
||||
var delta = geoVecSubtract(geoVecSubtract(currMouse, origMouse), nudge);
|
||||
|
||||
@@ -71,7 +71,7 @@ export function modeMove(context, entityIDs, baseGraph) {
|
||||
function startNudge(nudge) {
|
||||
if (_nudgeInterval) window.clearInterval(_nudgeInterval);
|
||||
_nudgeInterval = window.setInterval(function() {
|
||||
context.pan(nudge);
|
||||
context.map().pan(nudge);
|
||||
doMove(nudge);
|
||||
}, 50);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ export function modeMove(context, entityIDs, baseGraph) {
|
||||
|
||||
function move() {
|
||||
doMove();
|
||||
var nudge = geoViewportEdge(context.mouse(), context.map().dimensions());
|
||||
var nudge = geoViewportEdge(context.map().mouse(), context.map().dimensions());
|
||||
if (nudge) {
|
||||
startNudge(nudge);
|
||||
} else {
|
||||
|
||||
@@ -74,7 +74,7 @@ export function modeRotate(context, entityIDs) {
|
||||
}
|
||||
|
||||
|
||||
var currMouse = context.mouse();
|
||||
var currMouse = context.map().mouse();
|
||||
var currAngle = Math.atan2(currMouse[1] - _pivot[1], currMouse[0] - _pivot[0]);
|
||||
|
||||
if (typeof _prevAngle === 'undefined') _prevAngle = currAngle;
|
||||
|
||||
@@ -159,7 +159,7 @@ export function modeSelect(context, selectedIDs) {
|
||||
if (entity && entity.geometry(context.graph()) === 'relation') {
|
||||
_suppressMenu = true;
|
||||
} else {
|
||||
var point = context.mouse();
|
||||
var point = context.map().mouse();
|
||||
var viewport = geoExtent(context.projection.clipExtent()).polygon();
|
||||
|
||||
if (point && geoPointInPolygon(point, viewport)) {
|
||||
|
||||
@@ -67,7 +67,7 @@ export function operationCircularize(selectedIDs, context) {
|
||||
return 'multiple_blockers';
|
||||
}
|
||||
return actionDisableds[0];
|
||||
} else if (_extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
} else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large';
|
||||
} else if (someMissing()) {
|
||||
return 'not_downloaded';
|
||||
|
||||
@@ -72,7 +72,7 @@ export function operationDelete(selectedIDs, context) {
|
||||
|
||||
|
||||
operation.disabled = function() {
|
||||
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
if (extent.area() && extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large';
|
||||
} else if (someMissing()) {
|
||||
return 'not_downloaded';
|
||||
|
||||
@@ -84,7 +84,7 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
if (reason) return reason;
|
||||
}
|
||||
|
||||
if (disconnectingWayID && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
if (disconnectingWayID && extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large.single';
|
||||
} else if (disconnectingWayID && someMissing()) {
|
||||
return 'not_downloaded';
|
||||
|
||||
@@ -66,7 +66,7 @@ export function operationExtract(selectedIDs, context) {
|
||||
return reason;
|
||||
} else if (geometry === 'vertex' && selectedIDs.some(context.hasHiddenConnections)) {
|
||||
return 'connected_to_hidden';
|
||||
} else if (extent && extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
} else if (extent && extent.area() && extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large';
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export function operationMove(selectedIDs, context) {
|
||||
|
||||
|
||||
operation.disabled = function() {
|
||||
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
if (extent.area() && extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large';
|
||||
} else if (someMissing()) {
|
||||
return 'not_downloaded';
|
||||
|
||||
@@ -90,7 +90,7 @@ export function operationOrthogonalize(selectedIDs, context) {
|
||||
}
|
||||
return actionDisableds[0];
|
||||
} else if (_type !== 'corner' &&
|
||||
_extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
_extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large';
|
||||
} else if (someMissing()) {
|
||||
return 'not_downloaded';
|
||||
|
||||
@@ -44,7 +44,7 @@ export function operationReflect(selectedIDs, context, axis) {
|
||||
|
||||
// don't cache this because the visible extent could change
|
||||
operation.disabled = function() {
|
||||
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
if (extent.area() && extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large';
|
||||
} else if (someMissing()) {
|
||||
return 'not_downloaded';
|
||||
|
||||
@@ -26,7 +26,7 @@ export function operationRotate(selectedIDs, context) {
|
||||
|
||||
operation.disabled = function() {
|
||||
|
||||
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
if (extent.area() && extent.percentContainedIn(context.map().extent()) < 0.8) {
|
||||
return 'too_large';
|
||||
} else if (someMissing()) {
|
||||
return 'not_downloaded';
|
||||
|
||||
@@ -703,7 +703,7 @@ export function svgLabels(projection, context) {
|
||||
layers.selectAll('.nolabel')
|
||||
.classed('nolabel', false);
|
||||
|
||||
var mouse = context.mouse();
|
||||
var mouse = context.map().mouse();
|
||||
var graph = context.graph();
|
||||
var selectedIDs = context.selectedIDs();
|
||||
var ids = [];
|
||||
|
||||
+1
-1
@@ -354,7 +354,7 @@ export function uiInit(context) {
|
||||
return function() {
|
||||
if (d3_select('.combobox').size()) return;
|
||||
d3_event.preventDefault();
|
||||
context.pan(d, 100);
|
||||
context.map().pan(d, 100);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ export function uiSectionRawMembershipEditor(context) {
|
||||
});
|
||||
} else {
|
||||
|
||||
context.intersects(context.extent()).forEach(function(entity) {
|
||||
context.intersects(context.map().extent()).forEach(function(entity) {
|
||||
if (entity.type !== 'relation' || entity.id === entityID) return;
|
||||
|
||||
var value = baseDisplayLabel(entity);
|
||||
|
||||
+7
-11
@@ -11,45 +11,41 @@ import { tooltip } from '../util/tooltip';
|
||||
|
||||
|
||||
export function uiZoom(context) {
|
||||
|
||||
var zooms = [{
|
||||
id: 'zoom-in',
|
||||
icon: 'plus',
|
||||
title: t('zoom.in'),
|
||||
action: context.zoomIn,
|
||||
action: zoomIn,
|
||||
key: '+'
|
||||
}, {
|
||||
id: 'zoom-out',
|
||||
icon: 'minus',
|
||||
title: t('zoom.out'),
|
||||
action: context.zoomOut,
|
||||
action: zoomOut,
|
||||
key: '-'
|
||||
}];
|
||||
|
||||
|
||||
function zoomIn() {
|
||||
d3_event.preventDefault();
|
||||
context.zoomIn();
|
||||
context.map().zoomIn();
|
||||
}
|
||||
|
||||
|
||||
function zoomOut() {
|
||||
d3_event.preventDefault();
|
||||
context.zoomOut();
|
||||
context.map().zoomOut();
|
||||
}
|
||||
|
||||
|
||||
function zoomInFurther() {
|
||||
d3_event.preventDefault();
|
||||
context.zoomInFurther();
|
||||
context.map().zoomInFurther();
|
||||
}
|
||||
|
||||
|
||||
function zoomOutFurther() {
|
||||
d3_event.preventDefault();
|
||||
context.zoomOutFurther();
|
||||
context.map().zoomOutFurther();
|
||||
}
|
||||
|
||||
|
||||
return function(selection) {
|
||||
var button = selection.selectAll('button')
|
||||
.data(zooms)
|
||||
|
||||
Reference in New Issue
Block a user