瀏覽代碼

鼠标操作提示框

DESKTOP-CRQ4N2U\jintian 1 年之前
父節點
當前提交
c64880fd38
共有 2 個文件被更改,包括 139 次插入1 次删除
  1. 99 0
      src/jtMap3d/Assets/styles/tooltip.css
  2. 40 1
      src/jtMap3d/Widgets/common/common.js

+ 99 - 0
src/jtMap3d/Assets/styles/tooltip.css

@@ -0,0 +1,99 @@
+.twipsy {
+    display: block;
+    position: absolute;
+    visibility: visible;
+    max-width: 200px;
+    min-width: 100px;
+    padding: 5px;
+    font-size: 11px;
+    z-index: 1000;
+    opacity: 0.8;
+    -khtml-opacity: 0.8;
+    -moz-opacity: 0.8;
+    filter: alpha(opacity=80);
+}
+.twipsy.left .twipsy-arrow {
+    top: 50%;
+    right: 0;
+    margin-top: -5px;
+    border-top: 5px solid transparent;
+    border-bottom: 5px solid transparent;
+    border-left: 5px solid #000000;
+}
+.twipsy.right .twipsy-arrow {
+    top: 50%;
+    left: 0;
+    margin-top: -5px;
+    border-top: 5px solid transparent;
+    border-bottom: 5px solid transparent;
+    border-right: 5px solid #000000;
+}
+.twipsy-inner {
+    padding: 3px 8px;
+    background-color: #000000;
+    color: white;
+    text-align: center;
+    max-width: 200px;
+    text-decoration: none;
+    -webkit-border-radius: 4px;
+    -moz-border-radius: 4px;
+    border-radius: 4px;
+}
+.twipsy-arrow {
+    position: absolute;
+    width: 0;
+    height: 0;
+}
+
+/*
+css rules for the draw helper components
+*/
+
+.toolbar {
+    margin: 0px;
+    padding: 0px;
+    background: white;
+}
+
+.toolbar > .button {
+    margin: 5px;
+    padding: 5px;
+    border: 1px solid #eee;
+    cursor: pointer;
+}
+
+.toolbar > .button:hover {
+    background: #eee;
+}
+
+/*
+css rules for the infowindow
+*/
+
+.infoWindow {
+    position: absolute;
+    min-width: 100px;
+    max-width: 300px;
+}
+.infoWindow #frame {
+    padding: 10px;
+    border: 1px solid black;
+    background: white;
+}
+.infoWindow #close {
+    float: right;
+    margin: 5px 2px;
+    font-size: small;
+    color: gray;
+    cursor: pointer;
+}
+.infoWindow #arrow {
+    position: absolute;
+    bottom: -8px;
+    left: 50%;
+    margin-left: -10px;
+    border-right: 10px solid transparent;
+    border-left: 10px solid transparent;
+    border-top: 10px solid white;
+}
+

+ 40 - 1
src/jtMap3d/Widgets/common/common.js

@@ -166,7 +166,7 @@ export function getHeigthByPointMostDetailed(viewer, points) {
 		throw new Cesium.DeveloperError("points is required.");
 	}
 
-	let positions = Cesium.Cartographic.fromDegrees(points[0], points[1]);//经纬度转为世界坐标;
+	let positions = Cesium.Cartographic.fromDegrees(points[0], points[1]); //经纬度转为世界坐标;
 
 	let terrainProvider = viewer.terrainProvider;
 
@@ -178,3 +178,42 @@ export function getHeigthByPointMostDetailed(viewer, points) {
 		});
 	})
 }
+
+import '../../Assets/styles/tooltip.css';
+export function createTooltip(frameDiv) {
+
+	var tooltip = function(frameDiv) {
+
+		var div = document.createElement('DIV');
+		div.className = "twipsy right";
+
+		var arrow = document.createElement('DIV');
+		arrow.className = "twipsy-arrow";
+		div.appendChild(arrow);
+
+		var title = document.createElement('DIV');
+		title.className = "twipsy-inner";
+		div.appendChild(title);
+
+		this._div = div;
+		this._title = title;
+
+		// add to frame div and display coordinates
+		frameDiv.appendChild(div);
+	}
+
+	tooltip.prototype.setVisible = function(visible) {
+		this._div.style.display = visible ? 'block' : 'none';
+	}
+
+	tooltip.prototype.showAt = function(position, message) {
+		if (position && message) {
+			this.setVisible(true);
+			this._title.innerHTML = message;
+			this._div.style.left = position.x + 10 + "px";
+			this._div.style.top = (position.y - this._div.clientHeight / 2) + "px";
+		}
+	}
+
+	return new tooltip(frameDiv);
+}