Skip to content

Commit 534a3b8

Browse files
committed
【feature】增加ol-enhance 升级olms,增加warn ,对接text-keep-upright-alignment,text-writing-mode参数,优化河流沿线标注显示效果
1 parent c5eef5a commit 534a3b8

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

dist/ol/include-ol.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@
5555
var includes = (targetScript.getAttribute('include') || '').split(',');
5656
var excludes = (targetScript.getAttribute('exclude') || '').split(',');
5757
// 在线
58-
if (!inArray(includes, 'ol-debug') && !inArray(includes, '[email protected]') && !inArray(excludes, 'ol')) {
58+
if (!inArray(includes, 'ol-debug') && !inArray(includes, '[email protected]') && !inArray(includes, 'ol-enhance') && !inArray(excludes, 'ol')) {
5959
inputCSS(libsurl + '/openlayers/10.5.0/ol.min.css');
6060
inputScript(libsurl + '/openlayers/10.5.0/ol.min.js');
6161
}
62-
if (inArray(includes, '[email protected]')) {
62+
if (!inArray(includes, 'ol-enhance') && inArray(includes, '[email protected]')) {
6363
inputCSS(libsurl + '/openlayers/4.6.5/ol.css');
6464
inputScript(libsurl + '/openlayers/4.6.5/ol.js');
6565
}
66-
if (inArray(includes, 'ol-debug')) {
66+
if (inArray(includes, 'ol-enhance')) {
67+
inputCSS(libsurl + '/ol-enhance/7.5.2-1/ol-enhance.min.css');
68+
inputScript(libsurl + '/ol-enhance/7.5.2-1/ol-enhance.js');
69+
}
70+
if (!inArray(includes, 'ol-enhance') && inArray(includes, 'ol-debug')) {
6771
inputCSS(libsurl + '/openlayers/4.6.5/ol-debug.css');
6872
inputScript(libsurl + '/openlayers/4.6.5/ol-debug.js');
6973
}
@@ -89,7 +93,7 @@
8993
inputScript(libsurl + '/openlayers/ol3-echarts/1.3.6/ol3Echarts.min.js');
9094
}
9195
if (inArray(includes, 'ol-mapbox-style')) {
92-
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js');
96+
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-7/olms.js');
9397
}
9498
if (inArray(includes, 'deck')) {
9599
inputScript(libsurl + '/deck.gl/5.1.3/deck.gl.min.js');

dist/openlayers/include-openlayers.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@
5555
var includes = (targetScript.getAttribute('include') || '').split(',');
5656
var excludes = (targetScript.getAttribute('exclude') || '').split(',');
5757
// 在线
58-
if (!inArray(includes, 'ol-debug') && !inArray(includes, '[email protected]') && !inArray(excludes, 'ol')) {
58+
if (!inArray(includes, 'ol-debug') && !inArray(includes, '[email protected]') && !inArray(includes, 'ol-enhance') && !inArray(excludes, 'ol')) {
5959
inputCSS(libsurl + '/openlayers/10.5.0/ol.min.css');
6060
inputScript(libsurl + '/openlayers/10.5.0/ol.min.js');
6161
}
62-
if (inArray(includes, '[email protected]')) {
62+
if (!inArray(includes, 'ol-enhance') && inArray(includes, '[email protected]')) {
6363
inputCSS(libsurl + '/openlayers/4.6.5/ol.css');
6464
inputScript(libsurl + '/openlayers/4.6.5/ol.js');
6565
}
66-
if (inArray(includes, 'ol-debug')) {
66+
if (inArray(includes, 'ol-enhance')) {
67+
inputCSS(libsurl + '/ol-enhance/7.5.2-1/ol-enhance.min.css');
68+
inputScript(libsurl + '/ol-enhance/7.5.2-1/ol-enhance.js');
69+
}
70+
if (!inArray(includes, 'ol-enhance') && inArray(includes, 'ol-debug')) {
6771
inputCSS(libsurl + '/openlayers/4.6.5/ol-debug.css');
6872
inputScript(libsurl + '/openlayers/4.6.5/ol-debug.js');
6973
}
@@ -89,7 +93,7 @@
8993
inputScript(libsurl + '/openlayers/ol3-echarts/1.3.6/ol3Echarts.min.js');
9094
}
9195
if (inArray(includes, 'ol-mapbox-style')) {
92-
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js');
96+
inputScript(libsurl + '/openlayers/plugins/ol-mapbox-style/2.11.2-7/olms.js');
9397
}
9498
if (inArray(includes, 'deck')) {
9599
inputScript(libsurl + '/deck.gl/5.1.3/deck.gl.min.js');

src/openlayers/overlay/vectortile/MapboxStyles.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* <div style="padding: 20px;border: 1px solid #eee;border-left-width: 5px;border-radius: 3px;border-left-color: #ce4844;">
1919
* <p style="color: #ce4844">Notice</p>
2020
* <p style="font-size: 13px">该功能依赖 <a href='https://github.com/boundlessgeo/ol-mapbox-style'>ol-mapbox-style</a> 插件,请确认引入该插件。</p>
21-
* <a src="https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js">https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-6/olms.js</a>
21+
* <a src="https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-7/olms.js">https://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2-7/olms.js</a>
2222
* </div>
2323
* @modulecategory Overlay
2424
* @category Visualization VectorTile
@@ -32,7 +32,7 @@
3232
* 当配置 'source' 的 key 值时,source 为该值的 layer 会被加载;
3333
* 当配置为 'layer' 的 ID 数组时,指定的 layer 会被加载,注意被指定的 layer 需要有相同的 source。
3434
* 当不配置时,默认为 Mapbox Style JSON 的 `sources` 对象中的第一个。
35-
* @param {ol.Map} [options.map] - Openlayers 地图对象,仅用于面填充样式,若没有面填充样式可不填
35+
* @param {ol.Map} [options.map] - Openlayers 地图对象,仅用于面填充样式以及Background图层,若没有面填充样式或Background图层可不填
3636
* @param {ol.StyleFunction} [options.selectedStyle] -选中样式 Function。
3737
* @param {boolean} [options.withCredentials] - 请求是否携带 cookie。
3838
* @param {Object} [options.headers] - 请求头。
@@ -252,6 +252,7 @@
252252
_loadStyle(style) {
253253
if (Object.prototype.toString.call(style) == '[object Object]') {
254254
this._handleRelativeUrl(style, this.baseUrl);
255+
this._suggest(style);
255256
this._mbStyle = style;
256257
setTimeout(() => {
257258
this._resolve();
@@ -262,6 +263,7 @@
262263
.then(response => response.json())
263264
.then(mbStyle => {
264265
this._handleRelativeUrl(mbStyle, url);
266+
this._suggest(mbStyle);
265267
this._mbStyle = mbStyle;
266268
this._resolve();
267269
});
@@ -430,5 +432,14 @@
430432
}
431433
})
432434
}
435+
436+
_suggest(style){
437+
const needEnhance = style.layers.some(layer => {
438+
return layer.layout && (layer.layout['text-keep-upright-alignment'] === 'viewport' || layer.layout['text-writing-mode'] === 'line');
439+
});
440+
if(needEnhance){
441+
console.warn('Your mapbox style contains the SuperMap extension parameters text-keep-upright-alignment or text-writing-mode, please use ol-enhance.js instead of ol.js,https://iclient.supermap.io/web/libs/ol-enhance/7.5.2-1/ol-enhance.js')
442+
}
443+
}
433444
}
434445

0 commit comments

Comments
 (0)