mapshaper 0.6.66 → 0.6.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mapshaper.js +137 -120
- package/package.json +1 -1
- package/www/mapshaper-gui.js +189 -97
- package/www/mapshaper.js +137 -120
- package/www/page.css +4 -3
package/www/mapshaper-gui.js
CHANGED
|
@@ -4306,6 +4306,7 @@
|
|
|
4306
4306
|
|
|
4307
4307
|
if (opts.pinnable) classes += ' pinnable';
|
|
4308
4308
|
if (map.isActiveLayer(lyr)) classes += ' active';
|
|
4309
|
+
if (lyr.hidden) classes += ' invisible';
|
|
4309
4310
|
if (lyr.pinned) classes += ' pinned';
|
|
4310
4311
|
|
|
4311
4312
|
html = '<!-- ' + lyr.menu_id + '--><div class="' + classes + '">';
|
|
@@ -4384,10 +4385,24 @@
|
|
|
4384
4385
|
// init pin button
|
|
4385
4386
|
GUI.onClick(entry.findChild('img.black-eye'), function(e) {
|
|
4386
4387
|
var target = findLayerById(id);
|
|
4387
|
-
var
|
|
4388
|
+
var lyr = target.layer;
|
|
4389
|
+
var active = map.isActiveLayer(lyr);
|
|
4390
|
+
var hidden = false; // active && lyr.hidden || false;
|
|
4391
|
+
var pinned = false;
|
|
4392
|
+
var unpinned = false;
|
|
4388
4393
|
e.stopPropagation();
|
|
4389
|
-
|
|
4390
|
-
|
|
4394
|
+
if (active) {
|
|
4395
|
+
hidden = !lyr.hidden;
|
|
4396
|
+
pinned = !hidden && lyr.unpinned;
|
|
4397
|
+
unpinned = lyr.pinned && hidden;
|
|
4398
|
+
} else {
|
|
4399
|
+
pinned = !lyr.pinned;
|
|
4400
|
+
}
|
|
4401
|
+
lyr.hidden = hidden;
|
|
4402
|
+
lyr.unpinned = unpinned;
|
|
4403
|
+
map.setLayerPinning(target, pinned);
|
|
4404
|
+
entry.classed('pinned', pinned);
|
|
4405
|
+
entry.classed('invisible', hidden);
|
|
4391
4406
|
updatePinAllButton();
|
|
4392
4407
|
map.redraw();
|
|
4393
4408
|
});
|
|
@@ -4413,12 +4428,16 @@
|
|
|
4413
4428
|
GUI.onClick(entry, function() {
|
|
4414
4429
|
var target = findLayerById(id);
|
|
4415
4430
|
// don't select if user is typing or dragging
|
|
4416
|
-
if (
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4431
|
+
if (GUI.textIsSelected() || dragging) return;
|
|
4432
|
+
// undo any temporary hiding when layer is selected
|
|
4433
|
+
target.layer.hidden = false;
|
|
4434
|
+
if (!map.isActiveLayer(target.layer)) {
|
|
4435
|
+
model.selectLayer(target.layer, target.dataset);
|
|
4421
4436
|
}
|
|
4437
|
+
// close menu after a delay
|
|
4438
|
+
setTimeout(function() {
|
|
4439
|
+
gui.clearMode();
|
|
4440
|
+
}, 230);
|
|
4422
4441
|
});
|
|
4423
4442
|
}
|
|
4424
4443
|
|
|
@@ -7238,7 +7257,7 @@
|
|
|
7238
7257
|
self.clearSelection();
|
|
7239
7258
|
});
|
|
7240
7259
|
|
|
7241
|
-
gui.on('
|
|
7260
|
+
gui.on('shift_drag_start', function() {
|
|
7242
7261
|
self.clearHover();
|
|
7243
7262
|
});
|
|
7244
7263
|
|
|
@@ -7894,13 +7913,19 @@
|
|
|
7894
7913
|
|
|
7895
7914
|
function HighlightBox(gui, optsArg) {
|
|
7896
7915
|
var el = El('div').addClass('zoom-box').appendTo('body'),
|
|
7897
|
-
opts = Object.assign({
|
|
7916
|
+
opts = Object.assign({
|
|
7917
|
+
name: 'box',
|
|
7918
|
+
handles: false,
|
|
7919
|
+
persistent: false,
|
|
7920
|
+
draggable: false // does dragging the map draw a box
|
|
7921
|
+
}, optsArg),
|
|
7898
7922
|
box = new EventDispatcher(),
|
|
7899
7923
|
stroke = 2,
|
|
7900
7924
|
activeHandle = null,
|
|
7901
7925
|
prevXY = null,
|
|
7902
7926
|
boxCoords = null,
|
|
7903
7927
|
_on = false,
|
|
7928
|
+
_visible = false,
|
|
7904
7929
|
handles;
|
|
7905
7930
|
|
|
7906
7931
|
if (opts.classname) {
|
|
@@ -7910,19 +7935,20 @@
|
|
|
7910
7935
|
el.hide();
|
|
7911
7936
|
|
|
7912
7937
|
gui.on('map_rendered', function() {
|
|
7913
|
-
if (!_on) return;
|
|
7938
|
+
if (!_on || !_visible) return;
|
|
7914
7939
|
redraw();
|
|
7915
7940
|
});
|
|
7916
7941
|
|
|
7917
|
-
gui.on('
|
|
7942
|
+
gui.on('shift_drag', function(e) {
|
|
7918
7943
|
if (!_on) return;
|
|
7944
|
+
if (!opts.draggable) return;
|
|
7919
7945
|
boxCoords = getBoxCoords(e.data);
|
|
7920
7946
|
redraw();
|
|
7921
7947
|
box.dispatchEvent('drag');
|
|
7922
7948
|
});
|
|
7923
7949
|
|
|
7924
|
-
gui.on('
|
|
7925
|
-
if (!_on) return;
|
|
7950
|
+
gui.on('shift_drag_end', function(e) {
|
|
7951
|
+
if (!_on || !_visible || !opts.draggable) return;
|
|
7926
7952
|
boxCoords = getBoxCoords(e.data);
|
|
7927
7953
|
var pix = coordsToPix(boxCoords, gui.map.getExtent());
|
|
7928
7954
|
box.dispatchEvent('dragend', {map_bbox: pix});
|
|
@@ -7944,24 +7970,30 @@
|
|
|
7944
7970
|
});
|
|
7945
7971
|
|
|
7946
7972
|
document.addEventListener('mousemove', function(e) {
|
|
7947
|
-
if (!_on || !activeHandle || !prevXY || !boxCoords) return;
|
|
7973
|
+
if (!_on || !activeHandle || !prevXY || !boxCoords || !_visible) return;
|
|
7948
7974
|
var xy = {x: e.pageX, y: e.pageY};
|
|
7949
7975
|
var scale = gui.map.getExtent().getPixelSize();
|
|
7950
7976
|
var dx = (xy.x - prevXY.x) * scale;
|
|
7951
7977
|
var dy = -(xy.y - prevXY.y) * scale;
|
|
7952
|
-
var
|
|
7953
|
-
|
|
7978
|
+
var shifting = activeHandle.col == 'center' && activeHandle.row == 'center';
|
|
7979
|
+
var centered = gui.keyboard.shiftIsPressed() && !shifting;
|
|
7980
|
+
if (activeHandle.col == 'left' || shifting) {
|
|
7954
7981
|
boxCoords[0] += dx;
|
|
7982
|
+
if (centered) boxCoords[2] -= dx;
|
|
7955
7983
|
}
|
|
7956
|
-
if (activeHandle.col == 'right' ||
|
|
7984
|
+
if (activeHandle.col == 'right' || shifting) {
|
|
7957
7985
|
boxCoords[2] += dx;
|
|
7986
|
+
if (centered) boxCoords[0] -= dx;
|
|
7958
7987
|
}
|
|
7959
|
-
if (activeHandle.row == 'top' ||
|
|
7988
|
+
if (activeHandle.row == 'top' || shifting) {
|
|
7960
7989
|
boxCoords[3] += dy;
|
|
7990
|
+
if (centered) boxCoords[1] -= dy;
|
|
7961
7991
|
}
|
|
7962
|
-
if (activeHandle.row == 'bottom' ||
|
|
7992
|
+
if (activeHandle.row == 'bottom' || shifting) {
|
|
7963
7993
|
boxCoords[1] += dy;
|
|
7994
|
+
if (centered) boxCoords[3] -= dy;
|
|
7964
7995
|
}
|
|
7996
|
+
|
|
7965
7997
|
prevXY = xy;
|
|
7966
7998
|
redraw();
|
|
7967
7999
|
box.dispatchEvent('handle_drag');
|
|
@@ -8003,9 +8035,11 @@
|
|
|
8003
8035
|
box.hide = function() {
|
|
8004
8036
|
el.hide();
|
|
8005
8037
|
boxCoords = null;
|
|
8038
|
+
_visible = false;
|
|
8006
8039
|
};
|
|
8007
8040
|
|
|
8008
8041
|
box.show = function(x1, y1, x2, y2) {
|
|
8042
|
+
_visible = true;
|
|
8009
8043
|
var w = Math.abs(x1 - x2),
|
|
8010
8044
|
h = Math.abs(y1 - y2),
|
|
8011
8045
|
props = {
|
|
@@ -8116,13 +8150,14 @@
|
|
|
8116
8150
|
function MapNav(gui, ext, mouse) {
|
|
8117
8151
|
var wheel = new MouseWheel(mouse),
|
|
8118
8152
|
zoomTween = new Tween(Tween.sineInOut),
|
|
8119
|
-
zoomBox = new HighlightBox(gui), // .addClass('zooming'),
|
|
8120
|
-
|
|
8153
|
+
zoomBox = new HighlightBox(gui, {draggable: true, name: 'zoom-box'}), // .addClass('zooming'),
|
|
8154
|
+
shiftDrag = false,
|
|
8121
8155
|
zoomScaleMultiplier = 1,
|
|
8122
8156
|
inBtn, outBtn,
|
|
8123
8157
|
dragStartEvt,
|
|
8124
8158
|
_fx, _fy; // zoom foci, [0,1]
|
|
8125
8159
|
|
|
8160
|
+
// Was used in old frame view... remove?
|
|
8126
8161
|
this.setZoomFactor = function(k) {
|
|
8127
8162
|
zoomScaleMultiplier = k || 1;
|
|
8128
8163
|
};
|
|
@@ -8167,18 +8202,18 @@
|
|
|
8167
8202
|
if (disabled()) return;
|
|
8168
8203
|
if (!internal.layerHasGeometry(gui.model.getActiveLayer().layer)) return;
|
|
8169
8204
|
// zoomDrag = !!e.metaKey || !!e.ctrlKey; // meta is command on mac, windows key on windows
|
|
8170
|
-
|
|
8171
|
-
if (
|
|
8205
|
+
shiftDrag = !!e.shiftKey;
|
|
8206
|
+
if (shiftDrag) {
|
|
8172
8207
|
if (useBoxZoom()) zoomBox.turnOn();
|
|
8173
8208
|
dragStartEvt = e;
|
|
8174
|
-
gui.dispatchEvent('
|
|
8209
|
+
gui.dispatchEvent('shift_drag_start');
|
|
8175
8210
|
}
|
|
8176
8211
|
});
|
|
8177
8212
|
|
|
8178
8213
|
mouse.on('drag', function(e) {
|
|
8179
8214
|
if (disabled()) return;
|
|
8180
|
-
if (
|
|
8181
|
-
gui.dispatchEvent('
|
|
8215
|
+
if (shiftDrag) {
|
|
8216
|
+
gui.dispatchEvent('shift_drag', getBoxData(e));
|
|
8182
8217
|
} else {
|
|
8183
8218
|
ext.pan(e.dx, e.dy);
|
|
8184
8219
|
}
|
|
@@ -8187,9 +8222,9 @@
|
|
|
8187
8222
|
mouse.on('dragend', function(e) {
|
|
8188
8223
|
var bbox;
|
|
8189
8224
|
if (disabled()) return;
|
|
8190
|
-
if (
|
|
8191
|
-
|
|
8192
|
-
gui.dispatchEvent('
|
|
8225
|
+
if (shiftDrag) {
|
|
8226
|
+
shiftDrag = false;
|
|
8227
|
+
gui.dispatchEvent('shift_drag_end', getBoxData(e));
|
|
8193
8228
|
zoomBox.turnOff();
|
|
8194
8229
|
}
|
|
8195
8230
|
});
|
|
@@ -8207,7 +8242,9 @@
|
|
|
8207
8242
|
});
|
|
8208
8243
|
|
|
8209
8244
|
function useBoxZoom() {
|
|
8210
|
-
|
|
8245
|
+
var mode = gui.getMode();
|
|
8246
|
+
var disabled = ['selection_tool', 'box_tool', 'rectangle_tool'].includes(mode);
|
|
8247
|
+
return !disabled;
|
|
8211
8248
|
}
|
|
8212
8249
|
|
|
8213
8250
|
function getBoxData(e) {
|
|
@@ -8263,7 +8300,7 @@
|
|
|
8263
8300
|
|
|
8264
8301
|
function SelectionTool(gui, ext, hit) {
|
|
8265
8302
|
var popup = gui.container.findChild('.selection-tool-options');
|
|
8266
|
-
var box = new HighlightBox(gui);
|
|
8303
|
+
var box = new HighlightBox(gui, {draggable: true});
|
|
8267
8304
|
var coords = popup.findChild('.box-coords').hide();
|
|
8268
8305
|
var _on = false;
|
|
8269
8306
|
|
|
@@ -9582,11 +9619,90 @@
|
|
|
9582
9619
|
}
|
|
9583
9620
|
}
|
|
9584
9621
|
|
|
9585
|
-
|
|
9622
|
+
function initLineDrawing(gui, ext, mouse, hit) {
|
|
9623
|
+
var _on = false;
|
|
9624
|
+
var _coords;
|
|
9625
|
+
var _lastClick;
|
|
9626
|
+
|
|
9627
|
+
gui.on('interaction_mode_change', function(e) {
|
|
9628
|
+
_on = e.mode === 'draw-lines';
|
|
9629
|
+
gui.container.findChild('.map-layers').classed('draw-lines', _on);
|
|
9630
|
+
});
|
|
9631
|
+
|
|
9632
|
+
function active() {
|
|
9633
|
+
return _on;
|
|
9634
|
+
}
|
|
9635
|
+
|
|
9636
|
+
function extending() {
|
|
9637
|
+
return active() && !!_coords;
|
|
9638
|
+
}
|
|
9639
|
+
|
|
9640
|
+
function startPath(e) {
|
|
9641
|
+
|
|
9642
|
+
}
|
|
9643
|
+
|
|
9644
|
+
function extendPath(e) {
|
|
9645
|
+
|
|
9646
|
+
}
|
|
9647
|
+
|
|
9648
|
+
function finishPath() {
|
|
9649
|
+
_coords = null;
|
|
9650
|
+
}
|
|
9651
|
+
|
|
9652
|
+
gui.keyboard.on('keydown', function(evt) {
|
|
9653
|
+
if (!active()) return;
|
|
9654
|
+
if (evt.keyCode == 27) { // esc
|
|
9655
|
+
finishPath();
|
|
9656
|
+
}
|
|
9657
|
+
});
|
|
9658
|
+
|
|
9659
|
+
mouse.on('click', function(e) {
|
|
9660
|
+
if (!active()) return;
|
|
9661
|
+
// console.log('[click]', e)
|
|
9662
|
+
// addPoint(e.x, e.y);
|
|
9663
|
+
// gui.dispatchEvent('map-needs-refresh');
|
|
9664
|
+
_lastClick = e;
|
|
9665
|
+
});
|
|
9666
|
+
|
|
9667
|
+
// note: second click event is fired before this
|
|
9668
|
+
mouse.on('dblclick', function(e) {
|
|
9669
|
+
if (!active()) return;
|
|
9670
|
+
// block navigation
|
|
9671
|
+
e.stopPropagation();
|
|
9672
|
+
finishPath();
|
|
9673
|
+
|
|
9674
|
+
}, null, 3); // hit detection is priority 2
|
|
9675
|
+
|
|
9676
|
+
mouse.on('hover', function(e) {
|
|
9677
|
+
if (!active()) return;
|
|
9678
|
+
});
|
|
9679
|
+
|
|
9680
|
+
// x, y: pixel coordinates
|
|
9681
|
+
function addPoint(x, y) {
|
|
9682
|
+
var p = ext.translatePixelCoords(x, y);
|
|
9683
|
+
var target = hit.getHitTarget();
|
|
9684
|
+
var lyr = target.layer;
|
|
9685
|
+
var fid = lyr.shapes.length;
|
|
9686
|
+
if (lyr.data) {
|
|
9687
|
+
// this seems to work even for projected layers -- the data tables
|
|
9688
|
+
// of projected and original data seem to be shared.
|
|
9689
|
+
lyr.data.getRecords()[fid] = getEmptyDataRecord(lyr.data);
|
|
9690
|
+
}
|
|
9691
|
+
lyr.shapes[fid] = [p];
|
|
9692
|
+
updatePointCoords(target, fid);
|
|
9693
|
+
}
|
|
9694
|
+
|
|
9695
|
+
function getEmptyDataRecord(table) {
|
|
9696
|
+
return table.getFields().reduce(function(memo, name) {
|
|
9697
|
+
memo[name] = null;
|
|
9698
|
+
return memo;
|
|
9699
|
+
}, {});
|
|
9700
|
+
}
|
|
9701
|
+
}
|
|
9586
9702
|
|
|
9587
9703
|
function initDrawing(gui, ext, mouse, hit) {
|
|
9588
9704
|
initPointDrawing(gui, ext, mouse, hit);
|
|
9589
|
-
|
|
9705
|
+
initLineDrawing(gui, ext, mouse, hit);
|
|
9590
9706
|
}
|
|
9591
9707
|
|
|
9592
9708
|
function MapExtent(_position) {
|
|
@@ -9595,7 +9711,7 @@
|
|
|
9595
9711
|
_fullBounds, // full (zoomed-out) content bounds, including any padding
|
|
9596
9712
|
_strictBounds, // full extent must fit inside, if set
|
|
9597
9713
|
_self = this,
|
|
9598
|
-
_frame;
|
|
9714
|
+
_frame; // optional frame data (bbox, width, height)
|
|
9599
9715
|
|
|
9600
9716
|
_position.on('resize', function(e) {
|
|
9601
9717
|
if (ready()) {
|
|
@@ -9713,16 +9829,16 @@
|
|
|
9713
9829
|
return this.getTransform().transform(x, y);
|
|
9714
9830
|
};
|
|
9715
9831
|
|
|
9716
|
-
this.
|
|
9832
|
+
this.setFrameData = function(frame) {
|
|
9717
9833
|
_frame = frame || null;
|
|
9718
9834
|
};
|
|
9719
9835
|
|
|
9720
|
-
this.
|
|
9836
|
+
this.getFrameData = function() {
|
|
9721
9837
|
return _frame || null;
|
|
9722
9838
|
};
|
|
9723
9839
|
|
|
9724
9840
|
this.getSymbolScale = function() {
|
|
9725
|
-
if (!_frame) return
|
|
9841
|
+
if (!_frame) return 1;
|
|
9726
9842
|
var bounds = new Bounds(_frame.bbox);
|
|
9727
9843
|
var bounds2 = bounds.clone().transform(this.getTransform());
|
|
9728
9844
|
return bounds2.width() / _frame.width;
|
|
@@ -10335,12 +10451,12 @@
|
|
|
10335
10451
|
// (style.opacity < 1 ? '~' + style.opacity : '') +
|
|
10336
10452
|
(style.fillPattern ? '~' + style.fillPattern : '');
|
|
10337
10453
|
}
|
|
10338
|
-
|
|
10339
10454
|
return _self;
|
|
10340
10455
|
}
|
|
10341
10456
|
|
|
10342
10457
|
function getScaledLineScale(ext) {
|
|
10343
|
-
|
|
10458
|
+
var previewScale = ext.getSymbolScale();
|
|
10459
|
+
return previewScale == 1 ? getLineScale(ext) : previewScale;
|
|
10344
10460
|
}
|
|
10345
10461
|
|
|
10346
10462
|
// Vary line width according to zoom ratio.
|
|
@@ -10518,7 +10634,8 @@
|
|
|
10518
10634
|
if (pixRatio > 1) {
|
|
10519
10635
|
// bump up thin lines on retina, but not to more than 1px
|
|
10520
10636
|
// (tests on Chrome showed much faster rendering of 1px lines)
|
|
10521
|
-
strokeWidth = strokeWidth < 1 ? 1 : strokeWidth * pixRatio;
|
|
10637
|
+
// strokeWidth = strokeWidth < 1 ? 1 : strokeWidth * pixRatio;
|
|
10638
|
+
strokeWidth = strokeWidth * pixRatio;
|
|
10522
10639
|
}
|
|
10523
10640
|
ctx.lineCap = style.lineCap || 'round';
|
|
10524
10641
|
ctx.lineJoin = style.lineJoin || 'round';
|
|
@@ -10568,7 +10685,7 @@
|
|
|
10568
10685
|
|
|
10569
10686
|
function getSvgFurnitureTransform(ext) {
|
|
10570
10687
|
var scale = ext.getSymbolScale();
|
|
10571
|
-
var frame = ext.
|
|
10688
|
+
var frame = ext.getFrameData();
|
|
10572
10689
|
var p = ext.translateCoords(frame.bbox[0], frame.bbox[3]);
|
|
10573
10690
|
return internal.svg.getTransform(p, scale);
|
|
10574
10691
|
}
|
|
@@ -10579,7 +10696,7 @@
|
|
|
10579
10696
|
}
|
|
10580
10697
|
|
|
10581
10698
|
function renderFurniture(lyr, ext) {
|
|
10582
|
-
var frame = ext.
|
|
10699
|
+
var frame = ext.getFrameData(); // frame should be set if we're rendering a furniture layer
|
|
10583
10700
|
var obj = internal.getEmptyLayerForSVG(lyr, {});
|
|
10584
10701
|
if (!frame) {
|
|
10585
10702
|
stop$1('Missing map frame data');
|
|
@@ -10745,7 +10862,7 @@
|
|
|
10745
10862
|
//
|
|
10746
10863
|
function BoxTool(gui, ext, nav) {
|
|
10747
10864
|
var self = new EventDispatcher();
|
|
10748
|
-
var box = new HighlightBox(gui, {persistent: true, handles: true});
|
|
10865
|
+
var box = new HighlightBox(gui, {name: 'box-tool', persistent: true, handles: true, draggable: true});
|
|
10749
10866
|
var popup = gui.container.findChild('.box-tool-options');
|
|
10750
10867
|
var coords = popup.findChild('.box-coords');
|
|
10751
10868
|
var _on = false;
|
|
@@ -10792,7 +10909,7 @@
|
|
|
10792
10909
|
}
|
|
10793
10910
|
});
|
|
10794
10911
|
|
|
10795
|
-
gui.on('
|
|
10912
|
+
gui.on('shift_drag_start', function() {
|
|
10796
10913
|
// box.classed('zooming', inZoomMode());
|
|
10797
10914
|
hideCoords();
|
|
10798
10915
|
});
|
|
@@ -10858,7 +10975,7 @@
|
|
|
10858
10975
|
}
|
|
10859
10976
|
|
|
10860
10977
|
function RectangleControl(gui, hit) {
|
|
10861
|
-
var box = new HighlightBox(gui, {persistent: true, handles: true, classname: 'rectangles'});
|
|
10978
|
+
var box = new HighlightBox(gui, {name: 'rectangle-tool', persistent: true, handles: true, classname: 'rectangles', draggable: false});
|
|
10862
10979
|
var _on = false;
|
|
10863
10980
|
var dragInfo;
|
|
10864
10981
|
|
|
@@ -11530,12 +11647,12 @@
|
|
|
11530
11647
|
clearAllDisplayArcs();
|
|
11531
11648
|
|
|
11532
11649
|
// Reproject all visible map layers
|
|
11533
|
-
|
|
11650
|
+
getContentLayers().forEach(function(lyr) {
|
|
11534
11651
|
projectDisplayLayer(lyr, newCRS);
|
|
11535
11652
|
});
|
|
11536
11653
|
|
|
11537
11654
|
// kludge to make sure all layers have styles
|
|
11538
|
-
updateLayerStyles(
|
|
11655
|
+
updateLayerStyles(getContentLayers());
|
|
11539
11656
|
|
|
11540
11657
|
// Update map extent (also triggers redraw)
|
|
11541
11658
|
projectMapExtent(_ext, oldCRS, this.getDisplayCRS(), calcFullBounds());
|
|
@@ -11588,19 +11705,12 @@
|
|
|
11588
11705
|
updateVisibleMapLayers();
|
|
11589
11706
|
fullBounds = calcFullBounds();
|
|
11590
11707
|
|
|
11591
|
-
if (!prevLyr || prevLyr.tabular || _activeLyr.tabular
|
|
11708
|
+
if (!prevLyr || prevLyr.tabular || _activeLyr.tabular) {
|
|
11592
11709
|
needReset = true;
|
|
11593
11710
|
} else {
|
|
11594
11711
|
needReset = mapNeedsReset(fullBounds, _ext.getFullBounds(), _ext.getBounds(), e.flags);
|
|
11595
11712
|
}
|
|
11596
11713
|
|
|
11597
|
-
if (isFrameView()) {
|
|
11598
|
-
_nav.setZoomFactor(0.05); // slow zooming way down to allow fine-tuning frame placement // 0.03
|
|
11599
|
-
_ext.setFrame(calcFullBounds()); // TODO: remove redundancy with drawLayers()
|
|
11600
|
-
needReset = true; // snap to frame extent
|
|
11601
|
-
} else {
|
|
11602
|
-
_nav.setZoomFactor(1);
|
|
11603
|
-
}
|
|
11604
11714
|
_ext.setFullBounds(fullBounds, getStrictBounds()); // update 'home' button extent
|
|
11605
11715
|
|
|
11606
11716
|
if (needReset) {
|
|
@@ -11630,9 +11740,6 @@
|
|
|
11630
11740
|
_ext.on('change', function(e) {
|
|
11631
11741
|
if (_basemap) _basemap.refresh(); // keep basemap synced up (if enabled)
|
|
11632
11742
|
if (e.reset) return; // don't need to redraw map here if extent has been reset
|
|
11633
|
-
if (isFrameView()) {
|
|
11634
|
-
updateFrameExtent();
|
|
11635
|
-
}
|
|
11636
11743
|
drawLayers('nav');
|
|
11637
11744
|
});
|
|
11638
11745
|
|
|
@@ -11662,21 +11769,6 @@
|
|
|
11662
11769
|
};
|
|
11663
11770
|
}
|
|
11664
11771
|
|
|
11665
|
-
// Update map frame after user navigates the map in frame edit mode
|
|
11666
|
-
function updateFrameExtent() {
|
|
11667
|
-
var frameLyr = internal.findFrameLayer(model);
|
|
11668
|
-
var rec = frameLyr.data.getRecordAt(0);
|
|
11669
|
-
var viewBounds = _ext.getBounds();
|
|
11670
|
-
var w = viewBounds.width() * rec.width / _ext.width();
|
|
11671
|
-
var h = w * rec.height / rec.width;
|
|
11672
|
-
var cx = viewBounds.centerX();
|
|
11673
|
-
var cy = viewBounds.centerY();
|
|
11674
|
-
rec.bbox = [cx - w/2, cy - h/2, cx + w/2, cy + h/2];
|
|
11675
|
-
_ext.setFrame(getFrameData());
|
|
11676
|
-
_ext.setFullBounds(new Bounds(rec.bbox));
|
|
11677
|
-
_ext.reset();
|
|
11678
|
-
}
|
|
11679
|
-
|
|
11680
11772
|
function getStrictBounds() {
|
|
11681
11773
|
if (internal.isWebMercator(map.getDisplayCRS())) {
|
|
11682
11774
|
return getMapboxBounds();
|
|
@@ -11688,9 +11780,9 @@
|
|
|
11688
11780
|
_ext.setFullBounds(calcFullBounds(), getStrictBounds());
|
|
11689
11781
|
}
|
|
11690
11782
|
|
|
11691
|
-
function
|
|
11783
|
+
function getContentLayerBounds() {
|
|
11692
11784
|
var b = new Bounds();
|
|
11693
|
-
var layers =
|
|
11785
|
+
var layers = getContentLayers();
|
|
11694
11786
|
layers.forEach(function(lyr) {
|
|
11695
11787
|
b.mergeBounds(lyr.bounds);
|
|
11696
11788
|
});
|
|
@@ -11703,10 +11795,7 @@
|
|
|
11703
11795
|
}
|
|
11704
11796
|
|
|
11705
11797
|
function calcFullBounds() {
|
|
11706
|
-
|
|
11707
|
-
return internal.getFrameLayerBounds(internal.findFrameLayer(model));
|
|
11708
|
-
}
|
|
11709
|
-
var b = getVisibleContentBounds();
|
|
11798
|
+
var b = getContentLayerBounds();
|
|
11710
11799
|
|
|
11711
11800
|
// add margin
|
|
11712
11801
|
// use larger margin for small sizes
|
|
@@ -11736,25 +11825,21 @@
|
|
|
11736
11825
|
return !isPreviewView() && !!_activeLyr.tabular;
|
|
11737
11826
|
}
|
|
11738
11827
|
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
// var frameLyr = internal.findFrameLayer(model);
|
|
11744
|
-
// return !!frameLyr; // && isVisibleLayer(frameLyr)
|
|
11828
|
+
function findFrameLayer() {
|
|
11829
|
+
return getVisibleMapLayers().find(function(lyr) {
|
|
11830
|
+
return internal.isFrameLayer(lyr.layer, lyr.arcs);
|
|
11831
|
+
});
|
|
11745
11832
|
}
|
|
11746
11833
|
|
|
11747
|
-
//
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
return
|
|
11751
|
-
// var frameLyr = internal.findFrameLayer(model);
|
|
11752
|
-
// return isActiveLayer(frameLyr) && isVisibleLayer(frameLyr);
|
|
11834
|
+
// Preview view: symbols are scaled based on display size of frame layer
|
|
11835
|
+
function isPreviewView() {
|
|
11836
|
+
var data = getFrameData();
|
|
11837
|
+
return !!data;
|
|
11753
11838
|
}
|
|
11754
11839
|
|
|
11755
11840
|
function getFrameData() {
|
|
11756
|
-
var
|
|
11757
|
-
return
|
|
11841
|
+
var lyr = findFrameLayer();
|
|
11842
|
+
return lyr && internal.getFrameLayerData(lyr.layer, lyr.arcs) || null;
|
|
11758
11843
|
}
|
|
11759
11844
|
|
|
11760
11845
|
function clearAllDisplayArcs() {
|
|
@@ -11786,7 +11871,7 @@
|
|
|
11786
11871
|
});
|
|
11787
11872
|
}
|
|
11788
11873
|
|
|
11789
|
-
function
|
|
11874
|
+
function getContentLayers() {
|
|
11790
11875
|
var layers = getVisibleMapLayers();
|
|
11791
11876
|
if (isTableView()) return findActiveLayer(layers);
|
|
11792
11877
|
return layers.filter(function(o) {
|
|
@@ -11794,6 +11879,13 @@
|
|
|
11794
11879
|
});
|
|
11795
11880
|
}
|
|
11796
11881
|
|
|
11882
|
+
function getDrawableContentLayers() {
|
|
11883
|
+
return getContentLayers().filter(function(lyr) {
|
|
11884
|
+
if (isActiveLayer(lyr.layer) && lyr.layer.hidden) return false;
|
|
11885
|
+
return true;
|
|
11886
|
+
});
|
|
11887
|
+
}
|
|
11888
|
+
|
|
11797
11889
|
function getDrawableFurnitureLayers(layers) {
|
|
11798
11890
|
if (!isPreviewView()) return [];
|
|
11799
11891
|
return getVisibleMapLayers().filter(function(o) {
|
|
@@ -11844,7 +11936,7 @@
|
|
|
11844
11936
|
var layersMayHaveChanged = action != 'nav'; // !action;
|
|
11845
11937
|
var fullBounds;
|
|
11846
11938
|
var contentLayers = getDrawableContentLayers();
|
|
11847
|
-
var furnitureLayers = getDrawableFurnitureLayers();
|
|
11939
|
+
// var furnitureLayers = getDrawableFurnitureLayers();
|
|
11848
11940
|
if (!(_ext.width() > 0 && _ext.height() > 0)) {
|
|
11849
11941
|
// TODO: track down source of these errors
|
|
11850
11942
|
console.error("Collapsed map container, unable to draw.");
|
|
@@ -11852,7 +11944,7 @@
|
|
|
11852
11944
|
}
|
|
11853
11945
|
if (layersMayHaveChanged) {
|
|
11854
11946
|
// kludge to handle layer visibility toggling
|
|
11855
|
-
_ext.
|
|
11947
|
+
_ext.setFrameData(isPreviewView() ? getFrameData() : null);
|
|
11856
11948
|
updateFullBounds();
|
|
11857
11949
|
updateLayerStyles(contentLayers);
|
|
11858
11950
|
updateLayerStackOrder(model.getLayers());// update menu_order property of all layers
|