Skip to content

Commit ccc0a10

Browse files
committed
【update】提交最近完成的webmap对接功能
1 parent 29fd8b2 commit ccc0a10

File tree

6 files changed

+556
-4
lines changed

6 files changed

+556
-4
lines changed

examples/openlayers/iportalWebMap.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
33
*********************************************************************-->
44
<!DOCTYPE html>
5-
<html>
5+
<html style=" width: 100%;height: 100%;">
66
<head>
77
<meta charset="UTF-8">
88
<title data-i18n="resources.title_iportalWebMap"></title>
@@ -12,7 +12,7 @@
1212
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
1313
<div id="map" style="width: 100%;height:100%"></div>
1414
<script type="text/javascript">
15-
new ol.supermap.WebMap(44, {server: 'http://support.supermap.com.cn:8092'});
15+
new ol.supermap.DatavizWebMap('map', 'https://itest.supermapol.com/apps/viewer/922553127');
1616
</script>
1717
</body>
18-
</html>
18+

realese.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run release-openlayers

src/openlayers/core/StyleUtils.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,94 @@ export class StyleUtils {
580580
}
581581
return style;
582582
}
583+
584+
static toOpenLayersStyle(style, type) {
585+
style = style || this.getDefaultStyle();
586+
let olStyle = new ol.style.Style();
587+
let newImage, newFill, newStroke;
588+
const ZERO = 0.0000001;
589+
let {
590+
fillColor,
591+
fillOpacity,
592+
strokeColor,
593+
strokeWidth,
594+
strokeOpacity,
595+
radius,
596+
lineDash,
597+
lineCap,
598+
src,
599+
scale,
600+
//size,
601+
//imgSize,
602+
anchor
603+
} = style;
604+
let fillColorArray = this.hexToRgb(fillColor);
605+
if(fillColorArray){
606+
fillColorArray.push(fillOpacity);
607+
}
608+
609+
let strokeColorArray = this.hexToRgb(strokeColor);
610+
if(strokeColorArray){
611+
strokeColorArray.push(strokeOpacity);
612+
}
613+
if (type === "POINT") {
614+
if (src) {
615+
newImage = new ol.style.Icon({
616+
src: src,
617+
scale: scale,
618+
anchor: anchor
619+
});
620+
} else {
621+
newImage = new ol.style.Circle({
622+
radius: radius,
623+
fill: new ol.style.Fill({
624+
color: fillColorArray
625+
}),
626+
stroke: new ol.style.Stroke({
627+
width: strokeWidth || ZERO,
628+
color: strokeColorArray
629+
})
630+
});
631+
}
632+
olStyle.setImage(newImage);
633+
}
634+
/*else if (type === VectorFeatureType.LINE) {
635+
newStroke = new ol.style.Stroke({
636+
width: strokeWidth || ZERO,
637+
color: strokeColorArray,
638+
lineCap: lineCap || 'round',
639+
lineDash: this.getFormatLineDash(lineDash, strokeWidth)
640+
});
641+
olStyle.setStroke(newStroke);
642+
} else {
643+
newFill = new ol.style.Fill({
644+
color: fillColorArray
645+
});
646+
newStroke = new ol.style.Stroke({
647+
width: strokeWidth || ZERO,
648+
color: strokeColorArray,
649+
lineCap: lineCap || 'round',
650+
lineDash: this.getFormatLineDash(lineDash, strokeWidth)
651+
});
652+
olStyle.setFill(newFill);
653+
olStyle.setStroke(newStroke);
654+
}*/
655+
return olStyle;
656+
}
657+
/**
658+
* 将16进制的颜色,转换成rgb格式
659+
* @param hexColor
660+
* @returns {*[]}
661+
*/
662+
static hexToRgb (hexColor) {
663+
if (!hexColor) return;
664+
var s = hexColor.replace('#', '').split('');
665+
var rgb = [s[0] + s[1], s[2] + s[3], s[4] + s[5]];
666+
rgb = rgb.map(function (hex) {
667+
return parseInt(hex, 16);
668+
});
669+
return rgb;
670+
}
583671
}
584672

585673
ol.supermap.StyleUtils = StyleUtils;

src/openlayers/core/Util.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,44 @@ export class Util {
261261
var canvas = document.createElement('canvas');
262262
return Boolean(canvas && canvas.getContext("webgl2"));
263263
}
264+
static getRootUrl(url = window.location.href) {
265+
/*let tempRootUrl = {};
266+
let onlineUrl = 'https://www.supermapol.com/', itestUrl = 'https://itest.supermapol.com/';
267+
if (tempRootUrl[url]) return tempRootUrl[url];
268+
let rootUrl = "";
269+
if (url.indexOf(onlineUrl) === 0) {
270+
rootUrl = onlineUrl;
271+
} else if (url.indexOf(itestUrl) === 0) {
272+
rootUrl = itestUrl;
273+
} else {
274+
let regExp = /\/apps|\/web|\/manager|\/developer|\/services/i,
275+
index = url.search(regExp);
276+
let anchor = this.getAnchor(url);
277+
rootUrl += anchor.protocol + '//' + this.getHost(url) + '/';
278+
if (index > 0) {
279+
rootUrl += url.substring(rootUrl.length, index + 1);
280+
}
281+
}
282+
tempRootUrl[url] = rootUrl;
283+
return rootUrl;*/
284+
return 'http://127.0.0.1:8090/iportal/';
285+
}
286+
/**
287+
* 是否为字符串
288+
*
289+
* @param str
290+
*/
291+
static isString(str) {
292+
return (typeof str === 'string') && str.constructor === String;
293+
}
294+
/**
295+
* 字符串裁剪两边的空格
296+
*
297+
* @param str {String} 需要裁剪的字符串
298+
*/
299+
static trim(str) {
300+
return str.replace(/(^\s*)|(\s*$)/g, "");
301+
}
264302

265303

266304
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy