mapshaper 0.5.110 → 0.5.113
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/CHANGELOG.md +14 -0
- package/mapshaper.js +780 -581
- package/package.json +1 -1
- package/www/index.html +3 -0
- package/www/mapshaper-gui.js +94 -27
- package/www/mapshaper.js +780 -581
- package/www/page.css +26 -18
package/package.json
CHANGED
package/www/index.html
CHANGED
|
@@ -156,6 +156,9 @@
|
|
|
156
156
|
<div class="basemap-styles"></div>
|
|
157
157
|
<div>
|
|
158
158
|
<div class="close-btn btn dialog-btn">Close</div>
|
|
159
|
+
<div class="clear-btn btn dialog-btn disabled">Clear</div>
|
|
160
|
+
<div class="fade-btn btn dialog-btn disabled">Fade</div>
|
|
161
|
+
<!-- <div class="hide-btn btn dialog-btn disabled">Hide</div> -->
|
|
159
162
|
</div>
|
|
160
163
|
</div>
|
|
161
164
|
</div>
|
package/www/mapshaper-gui.js
CHANGED
|
@@ -1107,7 +1107,7 @@
|
|
|
1107
1107
|
|
|
1108
1108
|
utils$1.inherit(Checkbox, EventDispatcher);
|
|
1109
1109
|
|
|
1110
|
-
function
|
|
1110
|
+
function xSimpleButton(ref) {
|
|
1111
1111
|
var _el = El(ref),
|
|
1112
1112
|
_self = this,
|
|
1113
1113
|
_active = !_el.hasClass('disabled');
|
|
@@ -1134,7 +1134,31 @@
|
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
|
-
utils
|
|
1137
|
+
//utils.inherit(SimpleButton, EventDispatcher);
|
|
1138
|
+
|
|
1139
|
+
function SimpleButton(ref) {
|
|
1140
|
+
var _el = El(ref),
|
|
1141
|
+
_active = !_el.hasClass('disabled');
|
|
1142
|
+
|
|
1143
|
+
_el.active = function(a) {
|
|
1144
|
+
if (a === void 0) return _active;
|
|
1145
|
+
if (a !== _active) {
|
|
1146
|
+
_active = a;
|
|
1147
|
+
_el.toggleClass('disabled');
|
|
1148
|
+
}
|
|
1149
|
+
return _el;
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
// this.node = function() {return _el.node();};
|
|
1153
|
+
|
|
1154
|
+
function isVisible() {
|
|
1155
|
+
var el = _el.node();
|
|
1156
|
+
return el.offsetParent !== null;
|
|
1157
|
+
}
|
|
1158
|
+
return _el;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// utils.inherit(SimpleButton, EventDispatcher);
|
|
1138
1162
|
|
|
1139
1163
|
// @cb function(<FileList>)
|
|
1140
1164
|
function DropControl(gui, el, cb) {
|
|
@@ -5968,13 +5992,13 @@
|
|
|
5968
5992
|
var records = lyr.data.getRecords();
|
|
5969
5993
|
var symbols = lyr.shapes.map(function(shp, i) {
|
|
5970
5994
|
var d = records[i];
|
|
5971
|
-
var obj =
|
|
5972
|
-
internal.svg.importSymbol(d['svg-symbol']);
|
|
5995
|
+
var obj = internal.svg.renderPoint(d);
|
|
5973
5996
|
if (!obj || !shp) return null;
|
|
5997
|
+
obj.properties.class = 'mapshaper-svg-symbol';
|
|
5974
5998
|
obj.properties.transform = getSvgSymbolTransform(shp[0], ext);
|
|
5975
5999
|
obj.properties['data-id'] = i;
|
|
5976
6000
|
return obj;
|
|
5977
|
-
});
|
|
6001
|
+
}).filter(Boolean);
|
|
5978
6002
|
var obj = internal.getEmptyLayerForSVG(lyr, {});
|
|
5979
6003
|
obj.children = symbols;
|
|
5980
6004
|
return internal.svg.stringify(obj);
|
|
@@ -7663,7 +7687,7 @@
|
|
|
7663
7687
|
|
|
7664
7688
|
// update symbol by re-rendering it
|
|
7665
7689
|
function updateSymbol2(node, d, id) {
|
|
7666
|
-
var o = internal.svg.
|
|
7690
|
+
var o = internal.svg.renderStyledLabel(d); // TODO: symbol support
|
|
7667
7691
|
var activeLayer = hit.getHitTarget().layer;
|
|
7668
7692
|
var xy = activeLayer.shapes[id][0];
|
|
7669
7693
|
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
@@ -8187,13 +8211,16 @@
|
|
|
8187
8211
|
var styleIndex = {
|
|
8188
8212
|
opacity: 'opacity',
|
|
8189
8213
|
r: 'radius',
|
|
8190
|
-
fill: 'fillColor',
|
|
8191
|
-
stroke: 'strokeColor',
|
|
8214
|
+
'fill': 'fillColor',
|
|
8192
8215
|
'fill-pattern': 'fillPattern',
|
|
8216
|
+
'fill-opacity': 'fillOpacity',
|
|
8217
|
+
'stroke': 'strokeColor',
|
|
8193
8218
|
'stroke-width': 'strokeWidth',
|
|
8194
8219
|
'stroke-dasharray': 'lineDash',
|
|
8195
8220
|
'stroke-opacity': 'strokeOpacity',
|
|
8196
|
-
'
|
|
8221
|
+
'stroke-linecap': 'lineCap',
|
|
8222
|
+
'stroke-linejoin': 'lineJoin',
|
|
8223
|
+
'stroke-miterlimit': 'miterLimit'
|
|
8197
8224
|
},
|
|
8198
8225
|
// array of field names of relevant svg display properties
|
|
8199
8226
|
fields = getCanvasStyleFields(lyr).filter(function(f) {return f in styleIndex;}),
|
|
@@ -9033,14 +9060,17 @@
|
|
|
9033
9060
|
// (tests on Chrome showed much faster rendering of 1px lines)
|
|
9034
9061
|
strokeWidth = strokeWidth < 1 ? 1 : strokeWidth * pixRatio;
|
|
9035
9062
|
}
|
|
9036
|
-
ctx.lineCap = 'round';
|
|
9037
|
-
ctx.lineJoin = 'round';
|
|
9063
|
+
ctx.lineCap = style.lineCap || 'round';
|
|
9064
|
+
ctx.lineJoin = style.lineJoin || 'round';
|
|
9038
9065
|
ctx.lineWidth = strokeWidth * lineScale;
|
|
9039
9066
|
ctx.strokeStyle = style.strokeColor;
|
|
9040
9067
|
if (style.lineDash){
|
|
9041
9068
|
ctx.lineCap = 'butt';
|
|
9042
9069
|
ctx.setLineDash(style.lineDash.split(' '));
|
|
9043
9070
|
}
|
|
9071
|
+
if (style.miterLimit) {
|
|
9072
|
+
ctx.miterLimit = style.miterLimit;
|
|
9073
|
+
}
|
|
9044
9074
|
}
|
|
9045
9075
|
|
|
9046
9076
|
if (style.fillPattern) {
|
|
@@ -9214,12 +9244,14 @@
|
|
|
9214
9244
|
function reposition(target, type, ext) {
|
|
9215
9245
|
var container = el.findChild('.' + target.svg_id).node();
|
|
9216
9246
|
var elements;
|
|
9217
|
-
if (type == '
|
|
9218
|
-
elements =
|
|
9219
|
-
El.findAll('.mapshaper-svg-symbol', container);
|
|
9247
|
+
if (type == 'symbol') {
|
|
9248
|
+
elements = El.findAll('.mapshaper-svg-symbol', container);
|
|
9220
9249
|
repositionSymbols(elements, target.layer, ext);
|
|
9221
9250
|
} else if (type == 'furniture') {
|
|
9222
9251
|
repositionFurniture(container, target.layer, ext);
|
|
9252
|
+
} else {
|
|
9253
|
+
// container.getElementsByTagName('text')
|
|
9254
|
+
error('Unsupported symbol type:', type);
|
|
9223
9255
|
}
|
|
9224
9256
|
}
|
|
9225
9257
|
|
|
@@ -9249,14 +9281,15 @@
|
|
|
9249
9281
|
_svg.clear();
|
|
9250
9282
|
}
|
|
9251
9283
|
layers.forEach(function(lyr) {
|
|
9252
|
-
var
|
|
9253
|
-
if (!svgType || svgType == 'label') { // svg labels may have canvas dots
|
|
9284
|
+
var isSvgLayer = internal.layerHasSvgSymbols(lyr.layer) || internal.layerHasLabels(lyr.layer);
|
|
9285
|
+
//if (!svgType || svgType == 'label') { // svg labels may have canvas dots
|
|
9286
|
+
if (!isSvgLayer) { // svg labels may have canvas dots
|
|
9254
9287
|
drawCanvasLayer(lyr, _mainCanv);
|
|
9255
9288
|
}
|
|
9256
|
-
if (
|
|
9257
|
-
_svg.reposition(lyr,
|
|
9258
|
-
} else if (
|
|
9259
|
-
_svg.drawLayer(lyr,
|
|
9289
|
+
if (isSvgLayer && action == 'nav') {
|
|
9290
|
+
_svg.reposition(lyr, 'symbol');
|
|
9291
|
+
} else if (isSvgLayer) {
|
|
9292
|
+
_svg.drawLayer(lyr, 'symbol');
|
|
9260
9293
|
}
|
|
9261
9294
|
});
|
|
9262
9295
|
};
|
|
@@ -9308,9 +9341,9 @@
|
|
|
9308
9341
|
|
|
9309
9342
|
function getSvgLayerType(layer) {
|
|
9310
9343
|
var type = null;
|
|
9311
|
-
if (internal.
|
|
9312
|
-
type = '
|
|
9313
|
-
} else if (internal.
|
|
9344
|
+
if (internal.layerHasSvgSymbols(layer)) {
|
|
9345
|
+
type = 'symbol'; // also label + symbol
|
|
9346
|
+
} else if (internal.layerHasLabels(layer)) {
|
|
9314
9347
|
type = 'symbol';
|
|
9315
9348
|
}
|
|
9316
9349
|
return type;
|
|
@@ -9729,6 +9762,10 @@
|
|
|
9729
9762
|
|
|
9730
9763
|
function Basemap(gui, ext) {
|
|
9731
9764
|
var menu = gui.container.findChild('.basemap-options');
|
|
9765
|
+
// var hideBtn = new SimpleButton(menu.findChild('.hide-btn'));
|
|
9766
|
+
var fadeBtn = new SimpleButton(menu.findChild('.fade-btn'));
|
|
9767
|
+
var closeBtn = new SimpleButton(menu.findChild('.close-btn'));
|
|
9768
|
+
var clearBtn = new SimpleButton(menu.findChild('.clear-btn'));
|
|
9732
9769
|
var list = menu.findChild('.basemap-styles');
|
|
9733
9770
|
var container = gui.container.findChild('.basemap-container');
|
|
9734
9771
|
var basemapBtn = gui.container.findChild('.basemap-btn');
|
|
@@ -9740,6 +9777,7 @@
|
|
|
9740
9777
|
var map;
|
|
9741
9778
|
var activeStyle;
|
|
9742
9779
|
var loading = false;
|
|
9780
|
+
var faded = false;
|
|
9743
9781
|
|
|
9744
9782
|
if (params) {
|
|
9745
9783
|
init();
|
|
@@ -9750,11 +9788,35 @@
|
|
|
9750
9788
|
function init() {
|
|
9751
9789
|
gui.addMode('basemap', turnOn, turnOff, basemapBtn);
|
|
9752
9790
|
|
|
9753
|
-
|
|
9791
|
+
closeBtn.on('click', function() {
|
|
9754
9792
|
gui.clearMode();
|
|
9755
9793
|
turnOff();
|
|
9756
9794
|
});
|
|
9757
9795
|
|
|
9796
|
+
// hideBtn.on('mousedown', function() {
|
|
9797
|
+
// if (activeStyle) {
|
|
9798
|
+
// mapEl.css('visibility', 'hidden');
|
|
9799
|
+
// hidden = true;
|
|
9800
|
+
// }
|
|
9801
|
+
// })
|
|
9802
|
+
clearBtn.on('click', function() {
|
|
9803
|
+
if (activeStyle) {
|
|
9804
|
+
updateStyle(null);
|
|
9805
|
+
updateButtons();
|
|
9806
|
+
}
|
|
9807
|
+
});
|
|
9808
|
+
fadeBtn.on('click', function() {
|
|
9809
|
+
if (faded) {
|
|
9810
|
+
mapEl.css('opacity', 1);
|
|
9811
|
+
faded = false;
|
|
9812
|
+
fadeBtn.text('Fade');
|
|
9813
|
+
} else if (activeStyle) {
|
|
9814
|
+
mapEl.css('opacity', 0.35);
|
|
9815
|
+
faded = true;
|
|
9816
|
+
fadeBtn.text('Unfade');
|
|
9817
|
+
}
|
|
9818
|
+
});
|
|
9819
|
+
|
|
9758
9820
|
gui.on('map_click', function() {
|
|
9759
9821
|
// close menu if user click on the map
|
|
9760
9822
|
if (gui.getMode() == 'basemap') gui.clearMode();
|
|
@@ -9777,13 +9839,14 @@
|
|
|
9777
9839
|
// gui.state.dark_basemap = style && style.dark || false;
|
|
9778
9840
|
if (!style) {
|
|
9779
9841
|
gui.map.setDisplayCRS(null);
|
|
9780
|
-
|
|
9842
|
+
refresh();
|
|
9781
9843
|
} else if (map) {
|
|
9782
9844
|
map.setStyle(style.url);
|
|
9783
9845
|
refresh();
|
|
9784
9846
|
} else {
|
|
9785
9847
|
initMap();
|
|
9786
9848
|
}
|
|
9849
|
+
|
|
9787
9850
|
}
|
|
9788
9851
|
|
|
9789
9852
|
function updateButtons() {
|
|
@@ -9893,12 +9956,16 @@
|
|
|
9893
9956
|
}
|
|
9894
9957
|
|
|
9895
9958
|
function refresh() {
|
|
9896
|
-
if (!enabled() || !map || loading || !activeStyle) return;
|
|
9897
9959
|
var crs = gui.map.getDisplayCRS();
|
|
9898
|
-
|
|
9960
|
+
var off = !crs || !enabled() || !map || loading || !activeStyle;
|
|
9961
|
+
fadeBtn.active(!off);
|
|
9962
|
+
clearBtn.active(!off);
|
|
9963
|
+
if (off) {
|
|
9899
9964
|
hide();
|
|
9965
|
+
extentNote.hide();
|
|
9900
9966
|
return;
|
|
9901
9967
|
}
|
|
9968
|
+
|
|
9902
9969
|
if (!internal.isWebMercator(crs)) {
|
|
9903
9970
|
gui.map.setDisplayCRS(internal.getCRS('webmercator'));
|
|
9904
9971
|
}
|