@vtx/map 1.1.9 → 1.1.12
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/lib/VtxMap/AMap/AMap.js +17 -18
- package/lib/VtxMap/AMap/AMap.js.map +1 -1
- package/lib/VtxMap/OlMap/Map.css +43 -0
- package/lib/VtxMap/OlMap/Map.js +160 -17
- package/lib/VtxMap/OlMap/Map.js.map +1 -1
- package/lib/VtxMap/OlMap/Map.less +43 -0
- package/lib/VtxMap/images/defaultMarker.png +0 -0
- package/lib/VtxMap/images/defaultMarker_selected.png +0 -0
- package/lib/VtxSearchMap/VtxSearchMap.js +4 -2
- package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -1
- package/package.json +1 -1
package/lib/VtxMap/OlMap/Map.css
CHANGED
|
@@ -124,3 +124,46 @@
|
|
|
124
124
|
.ol-tooltip-static:before {
|
|
125
125
|
border-top-color: #ffcc33;
|
|
126
126
|
}
|
|
127
|
+
.ol-popup {
|
|
128
|
+
position: absolute;
|
|
129
|
+
background-color: white;
|
|
130
|
+
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
|
|
131
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
|
|
132
|
+
padding: 15px;
|
|
133
|
+
border-radius: 10px;
|
|
134
|
+
border: 1px solid #cccccc;
|
|
135
|
+
bottom: 12px;
|
|
136
|
+
left: -50px;
|
|
137
|
+
min-width: 280px;
|
|
138
|
+
}
|
|
139
|
+
.ol-popup:after,
|
|
140
|
+
.ol-popup:before {
|
|
141
|
+
top: 100%;
|
|
142
|
+
border: solid transparent;
|
|
143
|
+
content: " ";
|
|
144
|
+
height: 0;
|
|
145
|
+
width: 0;
|
|
146
|
+
position: absolute;
|
|
147
|
+
pointer-events: none;
|
|
148
|
+
}
|
|
149
|
+
.ol-popup:after {
|
|
150
|
+
border-top-color: white;
|
|
151
|
+
border-width: 10px;
|
|
152
|
+
left: 48px;
|
|
153
|
+
margin-left: -10px;
|
|
154
|
+
}
|
|
155
|
+
.ol-popup:before {
|
|
156
|
+
border-top-color: #cccccc;
|
|
157
|
+
border-width: 11px;
|
|
158
|
+
left: 48px;
|
|
159
|
+
margin-left: -11px;
|
|
160
|
+
}
|
|
161
|
+
.ol-popup-closer {
|
|
162
|
+
text-decoration: none;
|
|
163
|
+
position: absolute;
|
|
164
|
+
top: 2px;
|
|
165
|
+
right: 8px;
|
|
166
|
+
}
|
|
167
|
+
.ol-popup-closer:after {
|
|
168
|
+
content: "✖";
|
|
169
|
+
}
|
package/lib/VtxMap/OlMap/Map.js
CHANGED
|
@@ -496,6 +496,38 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
496
496
|
|
|
497
497
|
t.state.gis.addLayer(_layer3);
|
|
498
498
|
}
|
|
499
|
+
|
|
500
|
+
t.initPropsForUser();
|
|
501
|
+
} // 初始化对外方法
|
|
502
|
+
|
|
503
|
+
}, {
|
|
504
|
+
key: "initPropsForUser",
|
|
505
|
+
value: function initPropsForUser() {
|
|
506
|
+
var t = this;
|
|
507
|
+
|
|
508
|
+
t.state.gis["getCenter"] = function () {
|
|
509
|
+
return t.getCenter();
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
t.state.gis["setCenter"] = function (gt) {
|
|
513
|
+
t.setCenter(gt);
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
t.state.gis["getZoomLevel"] = function () {
|
|
517
|
+
return t.getZoomLevel();
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
t.state.gis["showInfoWindow"] = function (obj) {
|
|
521
|
+
return t.showInfoWindow(obj);
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
t.state.gis["hideInfoWindow"] = function () {
|
|
525
|
+
return t.hideInfoWindow();
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
t.state.gis["refresh"] = function () {
|
|
529
|
+
t.refresh();
|
|
530
|
+
};
|
|
499
531
|
} // 设置中心点
|
|
500
532
|
|
|
501
533
|
}, {
|
|
@@ -1630,6 +1662,43 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1630
1662
|
t.morepoints.map(function (item, index) {
|
|
1631
1663
|
item.value.clear();
|
|
1632
1664
|
});
|
|
1665
|
+
}
|
|
1666
|
+
/*
|
|
1667
|
+
* 添加信息窗口
|
|
1668
|
+
* params
|
|
1669
|
+
* @position: Array[longitude,latitude]
|
|
1670
|
+
* @content: String|HTML
|
|
1671
|
+
* @close: boolean
|
|
1672
|
+
*/
|
|
1673
|
+
|
|
1674
|
+
}, {
|
|
1675
|
+
key: "showInfoWindow",
|
|
1676
|
+
value: function showInfoWindow() {
|
|
1677
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1678
|
+
var t = this;
|
|
1679
|
+
|
|
1680
|
+
if (t.popupWindow) {
|
|
1681
|
+
t.hideInfoWindow();
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
t.popupWindow = new Popup({
|
|
1685
|
+
map: t.state.gis,
|
|
1686
|
+
position: params.position,
|
|
1687
|
+
innerHTML: params.content,
|
|
1688
|
+
close: params.close
|
|
1689
|
+
});
|
|
1690
|
+
t.popupWindow.showPopup();
|
|
1691
|
+
}
|
|
1692
|
+
}, {
|
|
1693
|
+
key: "hideInfoWindow",
|
|
1694
|
+
value: function hideInfoWindow() {
|
|
1695
|
+
var t = this;
|
|
1696
|
+
|
|
1697
|
+
if (t.popupWindow) {
|
|
1698
|
+
t.popupWindow.removePopup();
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
t.popupWindow = null;
|
|
1633
1702
|
} // 添加点
|
|
1634
1703
|
|
|
1635
1704
|
}, {
|
|
@@ -1682,12 +1751,6 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1682
1751
|
|
|
1683
1752
|
var style, icon, txt;
|
|
1684
1753
|
var myImage = new Image(cg.width, cg.height);
|
|
1685
|
-
canvasDataURL(item.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png"), {
|
|
1686
|
-
width: cg.width,
|
|
1687
|
-
height: cg.height
|
|
1688
|
-
}, function (base64) {
|
|
1689
|
-
myImage.src = base64;
|
|
1690
|
-
});
|
|
1691
1754
|
|
|
1692
1755
|
if (!!item.markerContent) {
|
|
1693
1756
|
var nodes = t.parseDom(item.markerContent)[0]; // 创建地图自定义覆盖物
|
|
@@ -1704,13 +1767,19 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1704
1767
|
});
|
|
1705
1768
|
t.state.gis.addOverlay(pop);
|
|
1706
1769
|
} else {
|
|
1707
|
-
//
|
|
1770
|
+
// item.url || `${configUrl.mapServerURL}/images/defaultMarker.png`,
|
|
1771
|
+
canvasDataURL(item.url || require("../images/defaultMarker.png"), {
|
|
1772
|
+
width: cg.width,
|
|
1773
|
+
height: cg.height
|
|
1774
|
+
}, function (base64) {
|
|
1775
|
+
myImage.src = base64;
|
|
1776
|
+
}); // 创建地图要素图标样式
|
|
1777
|
+
|
|
1708
1778
|
style = new ol.style.Style({
|
|
1709
1779
|
image: new ol.style.Icon({
|
|
1710
1780
|
anchor: [-cg.markerContentX, -cg.markerContentY],
|
|
1711
1781
|
anchorXUnits: 'pixels',
|
|
1712
1782
|
anchorYUnits: 'pixels',
|
|
1713
|
-
// src: item.url || `${configUrl.mapServerURL}/images/defaultMarker.png`,
|
|
1714
1783
|
img: myImage,
|
|
1715
1784
|
imgSize: [cg.width, cg.height],
|
|
1716
1785
|
opacity: cg.opacity,
|
|
@@ -1843,18 +1912,9 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1843
1912
|
cg = _objectSpread(_objectSpread({}, cg), item.config);
|
|
1844
1913
|
}
|
|
1845
1914
|
|
|
1846
|
-
var fStyle = gc.getStyle();
|
|
1847
|
-
var fText = fStyle.getText();
|
|
1848
|
-
|
|
1849
1915
|
var text, icon, _marker;
|
|
1850
1916
|
|
|
1851
1917
|
var myImage = new Image(cg.width, cg.height);
|
|
1852
|
-
canvasDataURL(item.url || "".concat(_default2["default"].mapServerURL, "/images/defaultMarker.png"), {
|
|
1853
|
-
width: cg.width,
|
|
1854
|
-
height: cg.height
|
|
1855
|
-
}, function (base64) {
|
|
1856
|
-
myImage.src = base64;
|
|
1857
|
-
});
|
|
1858
1918
|
|
|
1859
1919
|
if (item.markerContent) {
|
|
1860
1920
|
var overlay = t.state.gis.getOverlayById(item.id);
|
|
@@ -1863,6 +1923,12 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
1863
1923
|
overlay.setPosition([item.longitude, item.latitude]);
|
|
1864
1924
|
t.state.gis.changed();
|
|
1865
1925
|
} else {
|
|
1926
|
+
canvasDataURL(item.url || require("../images/defaultMarker.png"), {
|
|
1927
|
+
width: cg.width,
|
|
1928
|
+
height: cg.height
|
|
1929
|
+
}, function (base64) {
|
|
1930
|
+
myImage.src = base64;
|
|
1931
|
+
});
|
|
1866
1932
|
icon = new ol.style.Icon({
|
|
1867
1933
|
anchor: [-cg.markerContentX, -cg.markerContentY],
|
|
1868
1934
|
anchorXUnits: 'pixels',
|
|
@@ -3936,6 +4002,83 @@ var OlMap = /*#__PURE__*/function (_React$Component) {
|
|
|
3936
4002
|
var _default = OlMap;
|
|
3937
4003
|
exports["default"] = _default;
|
|
3938
4004
|
|
|
4005
|
+
var Popup = /*#__PURE__*/function (_React$Component2) {
|
|
4006
|
+
_inherits(Popup, _React$Component2);
|
|
4007
|
+
|
|
4008
|
+
var _super2 = _createSuper(Popup);
|
|
4009
|
+
|
|
4010
|
+
function Popup(props) {
|
|
4011
|
+
var _this8;
|
|
4012
|
+
|
|
4013
|
+
_classCallCheck(this, Popup);
|
|
4014
|
+
|
|
4015
|
+
_this8 = _super2.call(this);
|
|
4016
|
+
_this8.map = props.map;
|
|
4017
|
+
_this8.position = props.position;
|
|
4018
|
+
_this8.overlay = null;
|
|
4019
|
+
_this8.container = null;
|
|
4020
|
+
_this8.innerHTML = props.innerHTML;
|
|
4021
|
+
_this8.closeble = props.close;
|
|
4022
|
+
return _this8;
|
|
4023
|
+
} // 弹出框
|
|
4024
|
+
|
|
4025
|
+
|
|
4026
|
+
_createClass(Popup, [{
|
|
4027
|
+
key: "showPopup",
|
|
4028
|
+
value: function showPopup() {
|
|
4029
|
+
var t = this;
|
|
4030
|
+
this.removePopup(); // 获取弹出层DOM
|
|
4031
|
+
|
|
4032
|
+
t.container = document.createElement("div");
|
|
4033
|
+
t.container['className'] = "ol-popup";
|
|
4034
|
+
|
|
4035
|
+
if (t.closeble) {
|
|
4036
|
+
var close = document.createElement("a");
|
|
4037
|
+
close['className'] = "ol-popup-closer";
|
|
4038
|
+
close.addEventListener("click", function (e) {
|
|
4039
|
+
t.removePopup();
|
|
4040
|
+
});
|
|
4041
|
+
t.container.appendChild(close);
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
var content = document.createElement("div");
|
|
4045
|
+
t.container.appendChild(content);
|
|
4046
|
+
|
|
4047
|
+
if (t.overlay) {} else {
|
|
4048
|
+
// 创建Overlay弹出层绑定DOM
|
|
4049
|
+
t.overlay = new ol.Overlay({
|
|
4050
|
+
element: t.container,
|
|
4051
|
+
autoPan: {
|
|
4052
|
+
animation: {
|
|
4053
|
+
duration: 250
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
}); // 添加到map
|
|
4057
|
+
|
|
4058
|
+
t.map.addOverlay(t.overlay);
|
|
4059
|
+
} // 弹出层内容
|
|
4060
|
+
|
|
4061
|
+
|
|
4062
|
+
content.innerHTML = t.innerHTML; // 设置弹出层位置即可出现
|
|
4063
|
+
|
|
4064
|
+
t.overlay.setPosition(t.position);
|
|
4065
|
+
} // 清除弹出框
|
|
4066
|
+
|
|
4067
|
+
}, {
|
|
4068
|
+
key: "removePopup",
|
|
4069
|
+
value: function removePopup() {
|
|
4070
|
+
if (this.overlay) {
|
|
4071
|
+
this.container.remove(); // 设置位置undefined可达到隐藏清除弹出框
|
|
4072
|
+
|
|
4073
|
+
this.overlay.setPosition(undefined);
|
|
4074
|
+
this.overlay = null;
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
}]);
|
|
4078
|
+
|
|
4079
|
+
return Popup;
|
|
4080
|
+
}(_react["default"].Component);
|
|
4081
|
+
|
|
3939
4082
|
function getRgbColor(color, opacity) {
|
|
3940
4083
|
var reg = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
|
|
3941
4084
|
|