You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.2 KiB
82 lines
3.2 KiB
<!--
|
|
* @Author: hkh 838374358@qq.com
|
|
* @Date: 2023-09-13 16:27:14
|
|
* @LastEditors: hkh 838374358@qq.com
|
|
* @LastEditTime: 2023-09-14 17:53:52
|
|
* @FilePath: \smart-and-secure-residence\public\iframe.html
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%
|
|
-->
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<button onclick="floorChange('5','荷花一期')">荷花一期小区5号楼</button>
|
|
<button onclick="floorChange('6','荷花二期')">荷花二期小区6号楼</button>
|
|
<button onclick="floorChange('7','荷花三期')">荷花三期小区7号楼</button>
|
|
<button onclick="floorChange('8','红旗小区')">红旗小区8号楼</button>
|
|
<button onclick="floorChange('9','七凤苑')">七凤苑9号楼</button>
|
|
<button onclick="changeBtnShow()">显示隐藏子页面btn</button>
|
|
<!-- <iframe
|
|
id="map3d"
|
|
width="1000"
|
|
height="700"
|
|
src="http://124.70.129.134/zhihuianju/#/home?view=七凤苑"
|
|
frameborder="0"
|
|
></iframe> -->
|
|
<iframe
|
|
id="map3d"
|
|
width="1000"
|
|
height="700"
|
|
src="http://127.0.0.1:8080/#/home?view=七凤苑"
|
|
frameborder="0"
|
|
></iframe>
|
|
<script>
|
|
//监听子页面消息
|
|
if (typeof window.addEventListener != "undefined") {
|
|
// for ie9+、chrome
|
|
window.addEventListener("message", dealMessage, false);
|
|
} else if (typeof window.attachEvent != "undefined") {
|
|
// for ie8-
|
|
window.attachEvent("onmessage", dealMessage);
|
|
}
|
|
// 处理消息的回调函数
|
|
function dealMessage(e) {
|
|
console.log(e);
|
|
if (e.data.type == "iconClick") {
|
|
const params = JSON.parse(e.data.data);
|
|
console.log(`点击了icon${params.name},位置是${params.xiaoqu}`);
|
|
alert(`点击了icon${params.name},位置是${params.xiaoqu}`);
|
|
}
|
|
}
|
|
const frame = document.getElementById("map3d");
|
|
//定位到某小区某一栋楼
|
|
function floorChange(floor,name) {
|
|
frame.contentWindow.postMessage(
|
|
JSON.stringify({
|
|
event: "floorChange",
|
|
params: JSON.stringify({
|
|
floor,
|
|
name
|
|
}),
|
|
}),
|
|
"*",
|
|
);
|
|
}
|
|
function changeBtnShow() {
|
|
frame.contentWindow.postMessage(
|
|
JSON.stringify({
|
|
event: "changeBtnShow",
|
|
params: JSON.stringify({}),
|
|
}),
|
|
"*",
|
|
);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|