mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 05:12:13 +02:00
Configurable minimum editable zoom
This commit is contained in:
committed by
John Firebaugh
parent
9e9a4b3cc0
commit
17fb2f64e5
@@ -141,4 +141,17 @@ var iD = iD()
|
||||
.taginfo(iD.taginfo().endpoint('url'))
|
||||
.imagery(customImagery);
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
### Minimum Editable Zoom
|
||||
|
||||
The minimum zoom at which iD enters the edit mode is configured using the `iD().minEditableZoom()` accessor. The default value is 16. To change this initialise iD as
|
||||
|
||||
```js
|
||||
|
||||
var iD = iD().
|
||||
.minEditableZoom(zoom_level)
|
||||
|
||||
```
|
||||
|
||||
This should be set with caution for performance reasons. The OpenStreetMap API has a limitation of 50000 nodes per request.
|
||||
@@ -1,7 +1,7 @@
|
||||
iD.behavior.Edit = function(context) {
|
||||
function edit() {
|
||||
context.map()
|
||||
.minzoom(16);
|
||||
.minzoom(context.minEditableZoom());
|
||||
}
|
||||
|
||||
edit.off = function() {
|
||||
|
||||
+10
@@ -30,6 +30,16 @@ window.iD = function () {
|
||||
}
|
||||
};
|
||||
|
||||
/* Accessor for setting minimum zoom for editing features. */
|
||||
|
||||
var minEditableZoom = 16;
|
||||
context.minEditableZoom = function(_) {
|
||||
if (!arguments.length) return minEditableZoom;
|
||||
minEditableZoom = _;
|
||||
connection.tileZoom(_);
|
||||
return context;
|
||||
};
|
||||
|
||||
var history = iD.History(context),
|
||||
dispatch = d3.dispatch('enter', 'exit'),
|
||||
mode,
|
||||
|
||||
@@ -162,7 +162,7 @@ iD.Map = function(context) {
|
||||
iD.ui.flash(context.container())
|
||||
.select('.content')
|
||||
.text(t('cannot_zoom'));
|
||||
return setZoom(16, true);
|
||||
return setZoom(context.minEditableZoom(), true);
|
||||
}
|
||||
|
||||
projection
|
||||
@@ -342,7 +342,7 @@ iD.Map = function(context) {
|
||||
map.zoomTo = function(entity, zoomLimits) {
|
||||
var extent = entity.extent(context.graph()),
|
||||
zoom = map.extentZoom(extent);
|
||||
zoomLimits = zoomLimits || [16, 20];
|
||||
zoomLimits = zoomLimits || [context.minEditableZoom(), 20];
|
||||
map.centerZoom(extent.center(), Math.min(Math.max(zoom, zoomLimits[0]), zoomLimits[1]));
|
||||
};
|
||||
|
||||
@@ -406,7 +406,7 @@ iD.Map = function(context) {
|
||||
};
|
||||
|
||||
map.editable = function() {
|
||||
return map.zoom() >= 16;
|
||||
return map.zoom() >= context.minEditableZoom();
|
||||
};
|
||||
|
||||
map.minzoom = function(_) {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ iD.ui.Notice = function(context) {
|
||||
|
||||
var button = div.append('button')
|
||||
.attr('class', 'zoom-to notice')
|
||||
.on('click', function() { context.map().zoom(16); });
|
||||
.on('click', function() { context.map().zoom(context.minEditableZoom()); });
|
||||
|
||||
button.append('span')
|
||||
.attr('class', 'icon zoom-in-invert');
|
||||
|
||||
Reference in New Issue
Block a user