1205 lines
37 KiB
HTML
1205 lines
37 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||
|
||
<title>思极地图</title>
|
||
<style>
|
||
html,
|
||
body {
|
||
padding: 0;
|
||
margin: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
.fc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.fc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.yzfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.yzfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.tzfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.tzfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}.sqfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.sqfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}.wxfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.wxfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}.szfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.szfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}.czfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.czfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.ntfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.ntfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.lygfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.lygfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.hafc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.hafc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.ycfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.ycfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.xzfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.xzfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
.zjfc{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/fc.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.zjfc:hover{
|
||
background-image: url(images/fc-hot.png);
|
||
}
|
||
/* 土地样式 */
|
||
.td{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/td1.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.td:hover{
|
||
background-image: url(images/td-hot1.png);
|
||
}
|
||
.jd{
|
||
width: 31px;
|
||
height: 36px;
|
||
display: none;
|
||
z-index: 100;
|
||
background-image: url(images/td1.png);
|
||
position:relative;
|
||
z-index:9999;
|
||
}
|
||
|
||
.jd:hover{
|
||
background-image: url(images/td-hot1.png);
|
||
}
|
||
.wnd{
|
||
width: 400px;
|
||
height: 268px;
|
||
margin-left: -80px;
|
||
margin-top: 40px;
|
||
display: none;
|
||
background: url('images/wind.png') no-repeat;
|
||
background-size: 100% 100%;
|
||
position:fixed;
|
||
z-index:655361111;
|
||
}
|
||
|
||
.txt{
|
||
display: none;
|
||
width: 100%;
|
||
height: 35px;
|
||
margin-left: 0px;
|
||
margin-top: 10px;
|
||
text-align: center;
|
||
float: left;
|
||
color: white;
|
||
font-size: 12px;
|
||
font-weight: bold;
|
||
line-height: 35px;
|
||
overflow:hidden;
|
||
white-space: nowrap;
|
||
text-overflow: ellipsis;
|
||
-o-text-overflow:ellipsis;
|
||
}
|
||
|
||
.pos{
|
||
display: none;
|
||
width: 100%;
|
||
height: 20px;
|
||
margin-left: 0px;
|
||
margin-top: 0px;
|
||
text-align: center;
|
||
float: left;
|
||
color: white;
|
||
font-size: 12px;
|
||
line-height: 20px;
|
||
}
|
||
|
||
.labelBox{
|
||
display: inline-block;
|
||
width: 140px;
|
||
height: 45px;
|
||
/* padding-left: 20px; */
|
||
text-align: center;
|
||
line-height: 45px;
|
||
background: url(images/bottomM.png) no-repeat;;
|
||
background-size: 100% 100%;
|
||
color: #b4e9ff;
|
||
/* font-weight: 700; */
|
||
font-size: 16px;
|
||
}
|
||
.labelBox:hover{
|
||
background: url(images/bottomX.png) no-repeat;
|
||
color: #00fcff;
|
||
text-shadow: 0 0 5px #00fcff,
|
||
0 0 10px #00fcff,
|
||
0 0 15px #00fcff,
|
||
0 0 20px #00fcff ;
|
||
}
|
||
.labelBox:active{
|
||
background: url(images/bottomX.png) no-repeat;
|
||
color: #00fcff;
|
||
text-shadow: 0 0 5px #00fcff,
|
||
0 0 10px #00fcff,
|
||
0 0 15px #00fcff,
|
||
0 0 20px #00fcff ;
|
||
}
|
||
/* .label{
|
||
color: #000;
|
||
font-weight: 700;
|
||
|
||
} */
|
||
/* 搜索框 */
|
||
.search-middle {
|
||
position: absolute;
|
||
left: 50%;
|
||
top: 180px;
|
||
width: 356px;
|
||
height: 42px;
|
||
transform: translateX(-50%);
|
||
}
|
||
.search-middle .search-container {
|
||
position: relative;
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
.search-middle .search-container input {
|
||
width: 100%;
|
||
height: 100%;
|
||
padding-left: 15px;
|
||
background-color: transparent;
|
||
background-image: url(images/search-input.png);
|
||
background-size: contain;
|
||
border: 0;
|
||
border-radius: 0;
|
||
font-size: 12px;
|
||
color: rgb(211, 245, 255);
|
||
}
|
||
.search-middle .search-container input:focus {
|
||
outline: none;
|
||
}
|
||
.search-middle .search-container input::-webkit-input-placeholder {
|
||
color: rgb(211, 245, 255);
|
||
}
|
||
.search-middle .search-container button {
|
||
width: 45px;
|
||
height: 100%;
|
||
position: absolute;
|
||
right: 0;
|
||
top: 0;
|
||
background-color: transparent;
|
||
background: 10px 10px url(images/search-button.png) no-repeat;
|
||
border: 0;
|
||
border-radius: 0;
|
||
text-align: center;
|
||
line-height: 30px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
/* 对话框demo */
|
||
.dialogs-demo > div {
|
||
position: absolute;
|
||
width: 343px;
|
||
height: 166px;
|
||
background-image: url(images/dialog.png);
|
||
cursor: pointer;
|
||
}
|
||
.dialogs-demo > div:hover {
|
||
background-image: url(images/dialog-highlight.png);
|
||
}
|
||
.dialogs-demo > div img {
|
||
position: relative;
|
||
left: 215px;
|
||
top: -65px;
|
||
}
|
||
.dialogs-demo > div .text {
|
||
position: relative;
|
||
left: 38px;
|
||
top: -130px;
|
||
}
|
||
.dialogs-demo > div .text p:first-child {
|
||
font-weight: 700;
|
||
font-size: 16px;
|
||
color: rgb(132, 222, 231);
|
||
line-height: 45px;
|
||
}
|
||
.dialogs-demo > div .text p:last-child {
|
||
font-weight: 400;
|
||
font-size: 16px;
|
||
color: #fff;
|
||
}
|
||
.dialogs-demo > div.demo-1 {
|
||
left: 900px;
|
||
top: 312px;
|
||
}
|
||
.dialogs-demo > div.demo-2 {
|
||
left: 1100px;
|
||
top: 520px;
|
||
}
|
||
.dialogs-demo > div.demo-3 {
|
||
left: 723px;
|
||
top: 650px;
|
||
}
|
||
|
||
</style>
|
||
|
||
</head>
|
||
|
||
<body>
|
||
<div id="map" style="width: 100%; height: 100%;"></div>
|
||
|
||
<!-- <div style="position:absolute;bottom: 8rem;
|
||
right: 52rem;">
|
||
<div id="labelBox2" class="labelBox" style="color:#00fcff" onclick="show('jd','2')">
|
||
生产辅助用房
|
||
</div>
|
||
|
||
<div id="labelBox3" class="labelBox" onclick="show('bdz','3')">
|
||
生产用房
|
||
</div>
|
||
</div> -->
|
||
<script src="https://map.sgcc.com.cn/maps?v=3.0.0"></script>
|
||
<script src="js/jquery.min.js"></script>
|
||
<script type="text/javascript" src="js/socket.io.js"></script>
|
||
<!-- <script type="text/javascript" charset="utf-8">
|
||
|
||
</script> -->
|
||
<script id="mapScript">
|
||
// var btn1Obj = document.getElementById("labelBox1");
|
||
//object.attachEvent(event,function);
|
||
// btn1Obj.addEventListener("onclick",method1);
|
||
$("#labelBox1").on("click", function (e) {
|
||
$("#labelBox1").css("color", "#00fcff")
|
||
$("#labelBox1").css("font-weight", "700")
|
||
$("#labelBox1").css("text-shadow", "0 0 5px #00fcff,0 0 10px #00fcff,0 0 15px #00fcff,0 0 20px #00fcff ; ")
|
||
$("#labelBox2").css("color", "#b4e9ff")
|
||
$("#labelBox3").css("color", "#b4e9ff")
|
||
});
|
||
$("#labelBox2").on("click", function (e) {
|
||
$("#labelBox2").css("color", "#00fcff")
|
||
$("#labelBox2").css("font-weight", "700")
|
||
$("#labelBox2").css("text-shadow", "0 0 5px #00fcff,0 0 10px #00fcff,0 0 15px #00fcff,0 0 20px #00fcff ; ")
|
||
$("#labelBox1").css("color", "#b4e9ff")
|
||
$("#labelBox3").css("color", "#b4e9ff")
|
||
});
|
||
$("#labelBox3").on("click", function (e) {
|
||
$("#labelBox3").css("color", "#00fcff")
|
||
$("#labelBox3").css("font-weight", "700")
|
||
$("#labelBox3").css("text-shadow", "0 0 5px #00fcff,0 0 10px #00fcff,0 0 15px #00fcff,0 0 20px #00fcff ; ")
|
||
$("#labelBox1").css("color", "#b4e9ff")
|
||
$("#labelBox2").css("color", "#b4e9ff")
|
||
});
|
||
function method1(i,index) {
|
||
console.log("i",i)
|
||
console.log("index",index)
|
||
}
|
||
var map = null;
|
||
// var defaultLevel = 7.5;//默认层级
|
||
// var defaultArea = "nj";
|
||
var defaultLevel = 7.5;//默认层级
|
||
var defaultArea = "njData";
|
||
var defaultPos = "nanjing";//默认画线的位置
|
||
var cityBoundsData = new Object();
|
||
var cityOverColor = "#ff002a";//城市鼠标经过颜色
|
||
//socket
|
||
// var socket = io('wss://111.229.30.246:18443');
|
||
// var socket = io('ws://111.229.30.246:18444');
|
||
|
||
//本地socket id
|
||
// var socketId = "dtfdzy";// new Date().getTime().toString();//改为自己的固定ID
|
||
|
||
//document.title = socketId;
|
||
document.getElementById("map").oncontextmenu = function(e){
|
||
return false;
|
||
}
|
||
document.getElementById("map").onmousedown = function(e){
|
||
if(e.button ==2){
|
||
parent.show()
|
||
}
|
||
}
|
||
|
||
//注册
|
||
// socket.emit('register', socketId);
|
||
|
||
// //接收
|
||
// socket.on('receive', function (message) {
|
||
// switch (message) {
|
||
// case "0":
|
||
// console.log("注册成功!");
|
||
// break;
|
||
// default:
|
||
// console.log("其它消息:" + message);
|
||
// break;
|
||
// }
|
||
// });
|
||
|
||
// function send(val) {
|
||
// console.log("val",val)
|
||
// // var targetId = $("txtTarget").value;//目标页面socketId
|
||
// // var message = $("txtMessage").value;//发给目标页面的消息内容
|
||
// socket.emit('sendto', { target: 'fdzy', data: val });
|
||
// }
|
||
|
||
// function $(id) {
|
||
// return document.getElementById(id);
|
||
// }
|
||
var positions = {
|
||
"nj": { name: "南京市", lng: 118.802997, lat: 32.066366 },
|
||
"njData": { name: "南京市", lng: 118.802997, lat: 32.066366},
|
||
}
|
||
|
||
var layers = {}
|
||
var clickShow = false
|
||
var mapType = {
|
||
stardand: "aegis://styles/aegis/Streets",//标准
|
||
formated: "aegis://styles/aegis/Streets-Raster512",//栅格
|
||
pictures: "aegis://styles/aegis/Satellite512"//卫星
|
||
}
|
||
var njfc = []
|
||
var rightMap=''
|
||
var nameJD=''
|
||
function getMessageFromParent(val){
|
||
console.log("val",val)
|
||
$(".fc").hide();
|
||
$(".td").hide();
|
||
$(".wnd").hide();
|
||
nameJD = val
|
||
if(nameJD!=''){
|
||
console.log("1111")
|
||
loadJDdw(nameJD)
|
||
|
||
}else{
|
||
loadFC();
|
||
|
||
}
|
||
}
|
||
|
||
// 申请的key和sn
|
||
SGMap.tokenTask
|
||
.login("1a6fc765e72b36819428016bed30ff48", "5916636e73f03e5dbdf275f810fc7d62")
|
||
.then(function () {
|
||
initMap();
|
||
});
|
||
|
||
function initMap() {
|
||
var area = GetQueryString("area");
|
||
var lng = positions[defaultArea].lng;
|
||
var lat = positions[defaultArea].lat;
|
||
if (area != null) {
|
||
defaultArea = area;
|
||
lng = positions[defaultArea].lng;
|
||
lat = positions[defaultArea].lat;
|
||
}
|
||
|
||
map = new SGMap.Map({
|
||
// 地图绑定的DOM元素ID
|
||
container: "map",
|
||
// 地图样式
|
||
style: mapType.stardand,
|
||
// 默认缩放层级
|
||
zoom: defaultLevel,
|
||
// 地图中心点
|
||
center: [lng, lat],
|
||
//倾斜角度
|
||
pitch: 0,
|
||
// 地图默认字体
|
||
localIdeographFontFamily: "Microsoft YoHei"
|
||
});
|
||
loadFC();
|
||
loadTD();
|
||
MapFill();
|
||
loadMarkers(defaultArea);
|
||
//reportLocation();
|
||
};
|
||
function initMap1() {
|
||
var area = GetQueryString("area");
|
||
// console.log("defaultArea",defaultArea)
|
||
defaultArea="njData"
|
||
loadMarkers(defaultArea);
|
||
|
||
};
|
||
|
||
function MapFill() {
|
||
SGMap.plugin(['SGMap.DistrictTask']).then(function (res) {
|
||
var districtTask = new SGMap.DistrictTask()
|
||
|
||
districtTask
|
||
.searchDistrict({
|
||
keyword: '南京市',
|
||
// keyword: '江苏省', // 必填项,检索关键字,或者是行政区划编码
|
||
subdistrict: 2, // 选填项,设置显示下级行政区级数,0:不返回下级行政区; 1:返回下一级行政区; 2:返回下两级行政区; 3:返回下三级行政区;
|
||
extension: true, // 是否返回行政区边界坐标点
|
||
})
|
||
.then(function (result) {
|
||
$.get("data/map/js.json", function (res) {
|
||
layers.jiangsu = new Object();
|
||
layers.jiangsu.line = createLine("jiangsu", res.jiangsu, '#3787ff', 2).id;
|
||
layers.jiangsu.polygon = createPolygon("jiangsu", res.jiangsu, '#3787ff', 0.1).id;
|
||
|
||
createCities("nanjing",res.nanjing);
|
||
// createCities("zhenjiang",res.zhenjiang);
|
||
// createCities("suzhou",res.suzhou);
|
||
// createCities("changzhou",res.changzhou);
|
||
// createCities("wuxi",res.wuxi);
|
||
// createCities("nantong",res.nantong);
|
||
// createCities("taizhou",res.taizhou);
|
||
// createCities("yangzhou",res.yangzhou);
|
||
// createCities("yancheng",res.yancheng);
|
||
// createCities("huaian",res.huaian);
|
||
// createCities("suqian",res.suqian);
|
||
// createCities("lianyungang",res.lianyungang);
|
||
// createCities("xuzhou",res.xuzhou);
|
||
|
||
});
|
||
|
||
});
|
||
});
|
||
}
|
||
//画线
|
||
function createLine(name, data, color, lineWidth) {
|
||
var id = "l-" + name;
|
||
clearLayer(id);
|
||
var line = map.addLayer({
|
||
"id": id,
|
||
'type': 'line',
|
||
'source': {
|
||
'type': 'geojson',
|
||
'data': {
|
||
'type': 'FeatureCollection',
|
||
'features': [{
|
||
'type': 'Feature',
|
||
'geometry': {
|
||
'type': 'LineString',
|
||
'coordinates': data
|
||
}
|
||
}]
|
||
}
|
||
}, 'paint': {
|
||
'line-color': color,
|
||
'line-width': lineWidth
|
||
}
|
||
});
|
||
line.id = id;
|
||
return line;
|
||
}
|
||
|
||
//填充
|
||
function createPolygon(name, data, color, opacity) {
|
||
var id = "p-" + name;
|
||
clearLayer(id);
|
||
var polygon = map.addLayer({
|
||
"id": id,
|
||
'type': 'fill',
|
||
'source': {
|
||
'type': 'geojson',
|
||
'data': {
|
||
'type': 'FeatureCollection',
|
||
'features': [{
|
||
'type': 'Feature',
|
||
'geometry': {
|
||
'type': 'Polygon',
|
||
'coordinates': [data]
|
||
}
|
||
}]
|
||
}
|
||
},
|
||
'paint': {
|
||
'fill-color': color, // 默认值为黑色#000
|
||
'fill-opacity': opacity
|
||
}
|
||
});
|
||
polygon.id = id;
|
||
return polygon;
|
||
}
|
||
|
||
function createCities(cityName, cityData) {
|
||
|
||
visibleTD()
|
||
// visibleFC()
|
||
var hidePolygon = createPolygon("hide" + cityName, cityData, "#000000", 0);
|
||
createPolygon("show" + cityName, cityData, cityOverColor, 0.1);
|
||
createLine("show" + cityName, cityData, cityOverColor, 1);
|
||
// map.on('mouseover', hidePolygon.id, function (ev) {
|
||
// createPolygon("show" + cityName, cityData, cityOverColor, 0.1);
|
||
// createLine("show" + cityName, cityData, cityOverColor, 1);
|
||
// });
|
||
|
||
// map.on('mouseleave', hidePolygon.id, function (ev) {
|
||
// clearLayer("p-show" + cityName);
|
||
// clearLayer("l-show" + cityName);
|
||
// });
|
||
// map.on('click', hidePolygon.id, function (ev) {
|
||
// console.log("1111",cityData[0],cityName)
|
||
// map.easeTo({ center: [cityData[100][0], cityData[100][1]], zoom: getMapZoom1() });
|
||
|
||
// });
|
||
}
|
||
|
||
//清楚层
|
||
function clearLayer(layerId) {
|
||
if (map.getLayer(layerId) != undefined) {
|
||
map.removeLayer(layerId);
|
||
map.removeSource(layerId);
|
||
}
|
||
}
|
||
|
||
//获取地图层级
|
||
function getMapZoom() {
|
||
// console.log("getZoom",map.getZoom())
|
||
return map.getZoom()+2;
|
||
}
|
||
//获取地图层级
|
||
function getMapZoom1() {
|
||
// console.log("getZoom",map.getZoom())
|
||
// return map.getZoom();
|
||
return 10;
|
||
}
|
||
//设置地图层级
|
||
function setMapZoom(n) {
|
||
if (!isNaN(n) && n >= 0 && n <= 20)
|
||
map.setZoom(n);
|
||
}
|
||
|
||
//设置地图中心
|
||
function setMapCenter(lat, lng) {
|
||
map.setCenter([lng, lat]);
|
||
}
|
||
|
||
//获取地图当前中心点坐标
|
||
function getMapCenter() {
|
||
return map.getCenter();
|
||
}
|
||
|
||
//每秒汇报当前中心点坐标
|
||
function reportLocation() {
|
||
var centerPoint = getMapCenter();
|
||
console.log(centerPoint);
|
||
window.setTimeout("reportLocation()", 1000);
|
||
}
|
||
|
||
//地点跳转
|
||
function gotoPosition(posName) {
|
||
|
||
map.easeTo({ center: [positions[posName].lng, positions[posName].lat], zoom: getMapZoom() });
|
||
loadMarkers(posName);
|
||
|
||
clearLayer("l-" + defaultPos);//移除上一层区域
|
||
clearLayer("p-" + defaultPos);//移除上一层区域
|
||
defaultPos = posName;//设置为当前区域
|
||
createLine(posName, positions[posName].data, '#00d91f', 2);//为当前区域画线
|
||
createPolygon(posName, positions[posName].data, '#00d91f', 0.2);//为当前区域填充
|
||
}
|
||
|
||
//画marker点
|
||
function addMarker(markerData) {
|
||
var el = document.createElement("img");
|
||
el.cusData = markerData;
|
||
el.className = "marker";
|
||
// 自定义图标
|
||
el.src = markerData.icon;
|
||
el.style.width = markerData.width == undefined ? "64px" : markerData.width + "px";
|
||
el.style.height = markerData.height == undefined ? "64px" : markerData.height + "px";
|
||
|
||
// 如果不传el,会默认给一个蓝色水滴图标
|
||
var mk = new SGMap.Marker(el, {
|
||
// marker相对经纬度点坐标点的位置
|
||
anchor: "bottom",
|
||
// 相对于元素中心点,偏移的像素距离,负数代表向左和向上
|
||
offset: [markerData.xOffset == undefined ? 0 : markerData.xOffset, markerData.yOffset == undefined ? 0 : markerData.yOffset]
|
||
});
|
||
mk.setLngLat([markerData.lng, markerData.lat]);
|
||
mk.addTo(map);
|
||
el.addEventListener("click", function (e) {
|
||
/////////////////////////////////自定义输出内容//////////////////////////////////////
|
||
console.log("场景跳转@" + e.target.cusData.data);
|
||
|
||
// gotoPosition(e.target.cusData.data)
|
||
});
|
||
|
||
return mk;
|
||
}
|
||
|
||
//加载图标
|
||
var markerArray = new Array();
|
||
function loadMarkers(posName) {
|
||
for (var i in markerArray) {
|
||
markerArray[i].remove();
|
||
}
|
||
markerArray = new Array();
|
||
|
||
var markers = positions[posName].markers;
|
||
if (markers != undefined && markers != null) {
|
||
for (var i in markers) {
|
||
var markerData = markers[i];
|
||
markerArray.push(addMarker(markerData));
|
||
}
|
||
}
|
||
}
|
||
function loadFC() {
|
||
|
||
$.get("data/bdz.json", function (res) {
|
||
for (var i in res) {
|
||
var row = res[i];
|
||
var lng = parseFloat(row.position.substring(0, row.position.indexOf(',')));
|
||
var lat = parseFloat(row.position.substr(row.position.indexOf(',') + 1));
|
||
// console.log(lng, lat);
|
||
if (lng != NaN && lat != NaN && lng > 100 && lat < 100) {
|
||
//画marker点
|
||
var el = document.createElement("div");
|
||
el.className = "marker";
|
||
el.cusData = row;
|
||
el.lng = lng;
|
||
el.lat = lat;
|
||
el.setAttribute("class","fc");
|
||
var tip = document.createElement("div");
|
||
tip.setAttribute("class","wnd");
|
||
el.appendChild(tip);
|
||
el.tip = tip;
|
||
var txt = document.createElement("div");
|
||
txt.innerText = "龙园西路113号(枫亚湾5幢701)";
|
||
txt.setAttribute("class","txt");
|
||
tip.appendChild(txt);
|
||
tip.txt = txt;
|
||
var pos = document.createElement("div");
|
||
pos.innerText = "江苏省南京市";
|
||
pos.setAttribute("class","pos");
|
||
tip.appendChild(pos);
|
||
tip.pos = pos;
|
||
el.addEventListener("mouseover", function (e) {
|
||
|
||
$(e.target.tip).show();//(e.target.cusData.street+"("+e.target.cusData.zongdi+")");
|
||
$(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
$(e.target.tip.pos).html(e.target.cusData.jd);
|
||
/////////////////////////////////自定义输出内容//////////////////////////////////////
|
||
// console.log("场景跳转@",e.target.cusData);
|
||
});
|
||
el.addEventListener("mouseleave", function (e) {
|
||
$(e.target.tip).hide();
|
||
/////////////////////////////////自定义输出内容//////////////////////////////////////
|
||
//console.log("场景跳转@" + e.target.cusData);
|
||
});
|
||
el.addEventListener("click", function (e) {
|
||
console.log("e",e.target.cusData.jd)
|
||
window.parent.postMessage({ data:"变电站",params:e.target.cusData.jd,type:e.target.cusData.type},'*');
|
||
// $(e.target.tip).show();
|
||
});
|
||
// 如果不传el,会默认给一个蓝色水滴图标
|
||
var mk = new SGMap.Marker(el, {
|
||
// marker相对经纬度点坐标点的位置
|
||
anchor: "bottom",
|
||
// 相对于元素中心点,偏移的像素距离,负数代表向左和向上
|
||
offset: [0, 0]
|
||
});
|
||
mk.setLngLat([lng, lat]);
|
||
mk.addTo(map);
|
||
}
|
||
|
||
|
||
}
|
||
});
|
||
}
|
||
//基地数据
|
||
function loadTD() {
|
||
$.get("data/jd.json", function (res) {
|
||
for (var i in res) {
|
||
var row = res[i];
|
||
var lng = parseFloat(row.position.substring(0, row.position.indexOf(',')));
|
||
var lat = parseFloat(row.position.substr(row.position.indexOf(',') + 1));
|
||
// console.log(lng, lat);
|
||
if (lng != NaN && lat != NaN && lng > 100 && lat < 100) {
|
||
//画marker点
|
||
var el = document.createElement("div");
|
||
el.className = "marker";
|
||
el.cusData = row;
|
||
el.lng = lng;
|
||
el.lat = lat;
|
||
el.setAttribute("class","td");
|
||
var tip = document.createElement("div");
|
||
tip.setAttribute("class","wnd");
|
||
el.appendChild(tip);
|
||
el.tip = tip;
|
||
var txt = document.createElement("div");
|
||
txt.innerText = "龙园西路113号(枫亚湾5幢701)";
|
||
txt.setAttribute("class","txt");
|
||
tip.appendChild(txt);
|
||
tip.txt = txt;
|
||
var pos = document.createElement("div");
|
||
pos.innerText = "江苏省南京市";
|
||
pos.setAttribute("class","pos");
|
||
tip.appendChild(pos);
|
||
tip.pos = pos;
|
||
// var sideBar = document.getElementsByClassName('td');
|
||
|
||
// if (el.className.includes('act')) {
|
||
// console.log("act")
|
||
|
||
// }else{
|
||
// $(el.tip).hide();
|
||
// }
|
||
// $(el.tip).hide();
|
||
el.addEventListener("mouseover", function (e) {
|
||
$(e.target.tip).show();
|
||
$(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
$(e.target.tip.pos).html(e.target.cusData.jd);
|
||
});
|
||
el.addEventListener("mouseleave", function (e) {
|
||
if (e.target.className.includes('act')) {
|
||
|
||
}else{
|
||
$(e.target.tip).hide();
|
||
}
|
||
});
|
||
el.addEventListener("click", function (e) {
|
||
console.log("e",e.target.cusData.jd)
|
||
// parent.getFromIframe({ data:"办公用地",params:e.target.cusData.jd,type:e.target.cusData.type})
|
||
// siblingsRomoveClassAct(e.target, 'act',e.target.cusData)
|
||
|
||
// e.target.className += ' act';
|
||
window.parent.postMessage({ data:"变电站",params:e.target.cusData.jd,type:e.target.cusData.type},'*');
|
||
|
||
},true);
|
||
// 如果不传el,会默认给一个蓝色水滴图标
|
||
var mk = new SGMap.Marker(el, {
|
||
// marker相对经纬度点坐标点的位置
|
||
anchor: "bottom",
|
||
// 相对于元素中心点,偏移的像素距离,负数代表向左和向上
|
||
offset: [-15.5, -18]
|
||
});
|
||
mk.setLngLat([lng, lat]);
|
||
mk.addTo(map);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
function siblingsRomoveClassAct(e, className,cusData){
|
||
var nodeList = e.parentNode.children; //父级的子节点
|
||
for(var i=0; i<nodeList.length; i++){
|
||
// console.log("nodeList[i]111",nodeList[i])
|
||
//判断是否元素节点 且不是本身 移除要删除的类
|
||
if(nodeList[i].nodeType == 1 && nodeList[i] != e) {
|
||
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
|
||
nodeList[i].className = nodeList[i].className.replace(reg, ' ');
|
||
$(nodeList[i].tip).hide()
|
||
}else{
|
||
$(nodeList[i].tip).show()
|
||
$(nodeList[i].tip.txt).html(cusData.tudi);
|
||
$(nodeList[i].tip.pos).html(cusData.jd);
|
||
}
|
||
}
|
||
}
|
||
function siblingsRomoveClassActN(e, className,cusData){
|
||
var nodeList = e.children; //父级的子节点
|
||
loadJDQK()
|
||
for(var i=0; i<nodeList.length; i++){
|
||
// console.log("nodeList[i]111",nodeList[i])
|
||
//判断是否元素节点 且不是本身 移除要删除的类
|
||
if(nodeList[i].nodeType == 1 && nodeList[i] != e) {
|
||
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
|
||
nodeList[i].className = nodeList[i].className.replace(reg, ' ');
|
||
$(nodeList[i].tip).hide()
|
||
|
||
}else{
|
||
loadJDdw(val)
|
||
$(nodeList[i].tip).show()
|
||
$(nodeList[i].tip.txt).html(cusData.tudi);
|
||
$(nodeList[i].tip.pos).html(cusData.jd);
|
||
}
|
||
}
|
||
}
|
||
//基地定位
|
||
function loadJDQK() {
|
||
// $(".jd").hide();
|
||
$.get("data/jd.json", function (res) {
|
||
for (var i in res) {
|
||
var row = res[i];
|
||
var lng = parseFloat(row.position.substring(0, row.position.indexOf(',')));
|
||
var lat = parseFloat(row.position.substr(row.position.indexOf(',') + 1));
|
||
// console.log(lng, lat);
|
||
if (lng != NaN && lat != NaN && lng > 100 && lat < 100) {
|
||
//画marker点
|
||
var el = document.createElement("div");
|
||
|
||
el.className = "marker";
|
||
el.cusData = row;
|
||
el.lng = lng;
|
||
el.lat = lat;
|
||
el.setAttribute("class","jd");
|
||
var tip = document.createElement("div");
|
||
tip.setAttribute("class","wnd");
|
||
el.appendChild(tip);
|
||
el.tip = tip;
|
||
var txt = document.createElement("div");
|
||
txt.innerText = "龙园西路113号(枫亚湾5幢701)";
|
||
txt.setAttribute("class","txt");
|
||
tip.appendChild(txt);
|
||
tip.txt = txt;
|
||
var pos = document.createElement("div");
|
||
pos.innerText = "江苏省南京市";
|
||
pos.setAttribute("class","pos");
|
||
tip.appendChild(pos);
|
||
tip.pos = pos;
|
||
// $(el.tip).show();
|
||
// $(el.tip.txt).html(el.cusData.tudi);
|
||
// $(el.tip.pos).html(el.cusData.jd);
|
||
// $(el.tip).hide();
|
||
// visiblejddis()
|
||
$(el.tip).hide();
|
||
el.addEventListener("on", function (e) {
|
||
if(val== el.cusData.jd){
|
||
$(e.target.tip).show();//(e.target.cusData.street+"("+e.target.cusData.zongdi+")");
|
||
$(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
$(e.target.tip.pos).html(e.target.cusData.jd);
|
||
|
||
}else{
|
||
$(el.tip).hide();
|
||
}
|
||
});
|
||
|
||
el.addEventListener("mouseover", function (e) {
|
||
// $(e.target.tip).show();//(e.target.cusData.street+"("+e.target.cusData.zongdi+")");
|
||
// $(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
// $(e.target.tip.pos).html(e.target.cusData.jd);
|
||
});
|
||
el.addEventListener("mouseleave", function (e) {
|
||
// $(e.target.tip).hide();
|
||
});
|
||
el.addEventListener("click", function (e) {
|
||
console.log("e",e.target.cusData.jd)
|
||
// $(e.target.tip).show();
|
||
// $(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
// $(e.target.tip.pos).html(e.target.cusData.jd);
|
||
|
||
|
||
});
|
||
// 如果不传el,会默认给一个蓝色水滴图标
|
||
|
||
var mk = new SGMap.Marker(el, {
|
||
// marker相对经纬度点坐标点的位置
|
||
anchor: "bottom",
|
||
// 相对于元素中心点,偏移的像素距离,负数代表向左和向上
|
||
offset: [-15.5, -18]
|
||
});
|
||
|
||
mk.setLngLat([lng, lat]);
|
||
mk.addTo(map);
|
||
}
|
||
|
||
|
||
}
|
||
});
|
||
}
|
||
function loadJDdw(val) {
|
||
// visiblejddis()
|
||
// console.log("val",val)
|
||
$.get("data/jd.json", function (res) {
|
||
for (var i in res) {
|
||
var row = res[i];
|
||
var lng = parseFloat(row.position.substring(0, row.position.indexOf(',')));
|
||
var lat = parseFloat(row.position.substr(row.position.indexOf(',') + 1));
|
||
// console.log(lng, lat);
|
||
if (lng != NaN && lat != NaN && lng > 100 && lat < 100) {
|
||
//画marker点
|
||
var el = document.createElement("div");
|
||
el.className = "marker";
|
||
el.cusData = row;
|
||
el.lng = lng;
|
||
el.lat = lat;
|
||
el.setAttribute("class","jd");
|
||
var tip = document.createElement("div");
|
||
tip.setAttribute("class","wnd");
|
||
el.appendChild(tip);
|
||
el.tip = tip;
|
||
var txt = document.createElement("div");
|
||
txt.innerText = "龙园西路113号(枫亚湾5幢701)";
|
||
txt.setAttribute("class","txt");
|
||
tip.appendChild(txt);
|
||
tip.txt = txt;
|
||
var pos = document.createElement("div");
|
||
pos.innerText = "江苏省南京市";
|
||
pos.setAttribute("class","pos");
|
||
tip.appendChild(pos);
|
||
tip.pos = pos;
|
||
// $(el.tip).show();
|
||
// $(el.tip.txt).html(el.cusData.tudi);
|
||
// $(el.tip.pos).html(el.cusData.jd);
|
||
// $(el.tip).hide();
|
||
// $(el.tip).hide();
|
||
|
||
visiblejd()
|
||
if(val == el.cusData.jd){
|
||
$(el.tip).show();
|
||
$(el.tip.txt).html(el.cusData.tudi);
|
||
$(el.tip.pos).html(el.cusData.jd);
|
||
siblingsRomoveClassActN(el, 'act',el.cusData)
|
||
|
||
}else{
|
||
$(el.tip).hide();
|
||
}
|
||
el.addEventListener("mouseover", function (e) {
|
||
$(e.target.tip).show();//(e.target.cusData.street+"("+e.target.cusData.zongdi+")");
|
||
$(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
$(e.target.tip.pos).html(e.target.cusData.jd);
|
||
});
|
||
el.addEventListener("mouseleave", function (e) {
|
||
// $(e.target.tip).hide();
|
||
if (e.target.className.includes('act')) {
|
||
console.log("act")
|
||
|
||
}else{
|
||
$(e.target.tip).hide();
|
||
}
|
||
});
|
||
el.addEventListener("click", function (e) {
|
||
// $(e.target.tip).show();
|
||
// $(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
// $(e.target.tip.pos).html(e.target.cusData.jd);
|
||
console.log("e",e.target.cusData.jd)
|
||
parent.getFromIframe({ data:"办公用地",params:e.target.cusData.jd,type:e.target.cusData.type})
|
||
$(e.target.tip).show();
|
||
$(e.target.tip.txt).html(e.target.cusData.tudi);
|
||
$(e.target.tip.pos).html(e.target.cusData.jd);
|
||
siblingsRomoveClassAct(e.target, 'act',e.target.cusData)
|
||
|
||
e.target.className += ' act';
|
||
});
|
||
// 如果不传el,会默认给一个蓝色水滴图标
|
||
|
||
var mk = new SGMap.Marker(el, {
|
||
// marker相对经纬度点坐标点的位置
|
||
anchor: "bottom",
|
||
// 相对于元素中心点,偏移的像素距离,负数代表向左和向上
|
||
offset: [-15.5, -18]
|
||
});
|
||
|
||
mk.setLngLat([lng, lat]);
|
||
mk.addTo(map);
|
||
}
|
||
|
||
|
||
}
|
||
});
|
||
}
|
||
function siblingsRomoveClassActH(e, className){
|
||
var nodeList = e.parentNode.children; //父级的子节点
|
||
for(var i=0; i<nodeList.length; i++){
|
||
//判断是否元素节点 且不是本身 移除要删除的类
|
||
if(nodeList[i].nodeType == 1 && nodeList[i] != e) {
|
||
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
|
||
nodeList[i].className = nodeList[i].className.replace(reg, ' ');
|
||
}else{
|
||
|
||
}
|
||
}
|
||
}
|
||
function show(val,index){
|
||
if(val=='qb'){
|
||
visibleTD()
|
||
visibleFC()
|
||
$(".jd").hide();
|
||
}else if(val=='jd'){
|
||
visibleTD()
|
||
$(".fc").hide();
|
||
$(".jd").hide();
|
||
}else{
|
||
visibleFC()
|
||
$(".td").hide();
|
||
$(".jd").hide();
|
||
}
|
||
}
|
||
function visibleFC(val){
|
||
$(".fc").show();
|
||
// if(val)
|
||
// $(".fc").show();
|
||
// else
|
||
// $(".fc").hide();
|
||
|
||
}
|
||
|
||
function visibleTD(val){
|
||
$(".td").show();
|
||
|
||
}
|
||
//
|
||
function visiblejd(val){
|
||
$(".jd").show();
|
||
|
||
}
|
||
function visiblejddis(val){
|
||
$(".jd").hide();
|
||
|
||
}
|
||
/*
|
||
1.获取2个经纬度之间的距离
|
||
2.lng1 lat1 经纬度1
|
||
3.lng2 lat2 经纬度2
|
||
*/
|
||
function getDisance(lng1, lat1, lng2, lat2) {
|
||
var dis = 0;
|
||
var radius = 6378137;//地球的半径
|
||
var radLat1 = toRad(lat1);
|
||
var radLat2 = toRad(lat2);
|
||
var deltaLat = radLat1 - radLat2;
|
||
var deltaLng = toRad(lng1) - toRad(lng2);
|
||
var dis =
|
||
2 *
|
||
Math.asin(
|
||
Math.sqrt(
|
||
Math.pow(Math.sin(deltaLat / 2), 2) +
|
||
Math.cos(radLat1) *
|
||
Math.cos(radLat2) *
|
||
Math.pow(Math.sin(deltaLng / 2), 2)
|
||
)
|
||
);
|
||
|
||
return dis * radius;
|
||
}
|
||
|
||
//获取URL参数
|
||
function GetQueryString(name) {
|
||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||
var r = window.location.search.substr(1).match(reg);
|
||
if (r != null) return unescape(r[2]); return null;
|
||
}
|
||
</script>
|
||
|
||
</body>
|
||
|
||
</html> |