|
@@ -0,0 +1,884 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="zh-cn">
|
|
|
+<head>
|
|
|
+ <meta charset="utf-8" />
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
|
+ <title>华北油田生产指挥平台</title>
|
|
|
+ <link rel="stylesheet" href="./css/cascader.css" type="text/css">
|
|
|
+ <style>
|
|
|
+ html, body, #map {
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ overflow: hidden;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #ctrl {
|
|
|
+ z-index: 999;
|
|
|
+ position: absolute;
|
|
|
+ right: 70px;
|
|
|
+ top: 30px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #ctrl input {
|
|
|
+ cursor: pointer;
|
|
|
+ /*margin-left: 5px;*/
|
|
|
+ }
|
|
|
+
|
|
|
+ #info {
|
|
|
+ z-index: 999;
|
|
|
+ position: absolute !important;
|
|
|
+ height: 320px;
|
|
|
+ width: 240px;
|
|
|
+ right: 20px;
|
|
|
+ top: calc(50% - 160px);
|
|
|
+ border: 1px solid #999;
|
|
|
+ border-radius: 5px;
|
|
|
+ background-color: white;
|
|
|
+ overflow: auto;
|
|
|
+ padding: 3px 5px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ line-height: 25px;
|
|
|
+ font-size: 13px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #info span {
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ #info span:hover {
|
|
|
+ background-color: #DCDCFF;
|
|
|
+ }
|
|
|
+
|
|
|
+ .poi-changesway {
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*poi样式*/
|
|
|
+ #poiSearch {
|
|
|
+ position: absolute;
|
|
|
+ left: 75px;
|
|
|
+ top: 20px;
|
|
|
+ overflow: hidden;
|
|
|
+ pointer-events: none;
|
|
|
+ height: 621px;
|
|
|
+ }
|
|
|
+ div.search{
|
|
|
+ height: 40px;
|
|
|
+ width: 405px;
|
|
|
+ float: left;
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+ div.search form{
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ div.search form input:nth-child(2){
|
|
|
+ width: 300px;
|
|
|
+ height: 100%;
|
|
|
+ font-size: 16px;
|
|
|
+ text-indent: 40px;
|
|
|
+ border: none;
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+ div.search form input:nth-child(3){
|
|
|
+ width: 100px;
|
|
|
+ height: 100%;
|
|
|
+ font-size: 16px;
|
|
|
+ letter-spacing: 5px;
|
|
|
+ border: none;
|
|
|
+ background-color: cornflowerblue;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ div.search form img{
|
|
|
+ position: absolute;
|
|
|
+ left: 10px;
|
|
|
+ /*transform: translateX(-250px);*/
|
|
|
+ margin-top: 10px;
|
|
|
+ /*margin-left: 10px;*/
|
|
|
+ height: 20px;
|
|
|
+ }
|
|
|
+ select {
|
|
|
+ width: 150px;
|
|
|
+ height: 100%;
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
+ .option{
|
|
|
+ /*用div的样式代替select的样式*/
|
|
|
+ /*margin: 100px;*/
|
|
|
+ float: left;
|
|
|
+ margin-left: 2px;
|
|
|
+ width: 140px;
|
|
|
+ height: 40px;
|
|
|
+ /*border-radius: 5px;*/
|
|
|
+ /*盒子阴影修饰作用,自己随意*/
|
|
|
+ /* box-shadow: 0 0 5px #ccc;*/
|
|
|
+ border: 1px solid #cccccc;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ .option select{
|
|
|
+ /*清除select的边框样式*/
|
|
|
+ border: none;
|
|
|
+ /*清除select聚焦时候的边框颜色*/
|
|
|
+ outline: none;
|
|
|
+ /*将select的宽高等于div的宽高*/
|
|
|
+ width: 100%;
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ /*隐藏select的下拉图标*/
|
|
|
+ appearance: none;
|
|
|
+ -webkit-appearance: none;
|
|
|
+ -moz-appearance: none;
|
|
|
+ /*通过padding-left的值让文字居中*/
|
|
|
+ padding-left: 20px;
|
|
|
+ }
|
|
|
+ /*使用伪类给select添加自己想用的图标*/
|
|
|
+ .option:after{
|
|
|
+ content: "";
|
|
|
+ width: 14px;
|
|
|
+ height: 8px;
|
|
|
+ background: url(arrow-down.png) no-repeat center;
|
|
|
+ /*通过定位将图标放在合适的位置*/
|
|
|
+ position: absolute;
|
|
|
+ right: 10px;
|
|
|
+ top: 41%;
|
|
|
+ /*给自定义的图标实现点击下来功能*/
|
|
|
+ pointer-events: none;
|
|
|
+ }
|
|
|
+ .checkBox {
|
|
|
+ float: left;
|
|
|
+ margin-top: 5px;
|
|
|
+ }
|
|
|
+ #well, #station, #pipe, #factory, #geology, #power{
|
|
|
+ width: 16px;
|
|
|
+ height: 16px;
|
|
|
+ }
|
|
|
+ .button1 {
|
|
|
+ margin-left: 2px;
|
|
|
+ width: 120px;
|
|
|
+ padding:3px;
|
|
|
+ background-color: cornflowerblue;
|
|
|
+ border-color: #357ebd;
|
|
|
+ color: #fff;
|
|
|
+ -moz-border-radius: 10px;
|
|
|
+ -webkit-border-radius: 10px;
|
|
|
+ border-radius: 10px; /* future proofing */
|
|
|
+ -khtml-border-radius: 10px; /* for old Konqueror browsers */
|
|
|
+ text-align: center;
|
|
|
+ vertical-align: middle;
|
|
|
+ border: 1px solid transparent;
|
|
|
+ font-weight: 900;
|
|
|
+ font-size:125%;
|
|
|
+ }
|
|
|
+ .input1 {
|
|
|
+ width: 100px;
|
|
|
+ height:32px;
|
|
|
+ }
|
|
|
+ .buttonGroup {
|
|
|
+ width: 600px;
|
|
|
+ height: 60px;
|
|
|
+ float: right;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+ .esriSimpleSliderTL{
|
|
|
+ left: unset !important;
|
|
|
+ right: 20px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ <!--测试环境使用-->
|
|
|
+ <link href='https://js.arcgis.com/3.27/esri/css/esri.css' rel='stylesheet' />
|
|
|
+ <script src='jquery.min.js'></script>
|
|
|
+ <script src='https://js.arcgis.com/3.27/init.js' type='text/javascript'></script>
|
|
|
+ <script src='init-gmap.js?v=1.15.9' type='text/javascript'></script>
|
|
|
+ <script src='init-gcontrols.js?v=1.0.5' type='text/javascript'></script>
|
|
|
+
|
|
|
+ <!--正式环境使用
|
|
|
+ <link href='http://a4.petrochina/gisapi/esri/css/esri.css' rel='stylesheet' />
|
|
|
+ <script src='http://a4.petrochina/gisapi/third/jquery/jquery-1.9.1.min.js'></script>
|
|
|
+ <script src='http://a4.petrochina/gisapi/init.js' type='text/javascript'></script>
|
|
|
+ <script src='http://a4.petrochina/gisapi/lib/init-gmap.js?v=1.15.9' type='text/javascript'></script>
|
|
|
+ <script src='http://a4.petrochina/gisapi/lib/init-gcontrols.js?v=1.0.5' type='text/javascript'></script> -->
|
|
|
+
|
|
|
+ <script>
|
|
|
+ var map = null, app = { token: "d4b2b740-9814-4d75-9cda-dac96fc2bc10" };
|
|
|
+ var graLayer = null;
|
|
|
+ var testers = [{"x":116.22299368359181,"y":38.65785928124781},{"x":115.87417776562305,"y":38.68573597570963},{"x":115.95657522656056,"y":38.794993532692935},{"x":116.0087602851543,"y":38.61280477070679},{"x":115.65719778515431,"y":38.65785928124781},{"x":116.01974661327931,"y":38.91476998760284},{"x":116.59652883984181,"y":38.6278260872767},{"x":116.11313040234178,"y":38.32895709204688},{"x":115.32760794140432,"y":38.58275270026599}];
|
|
|
+ require(
|
|
|
+ [
|
|
|
+ "gmap/MapControl", "esri/Color", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol",
|
|
|
+ "esri/symbols/SimpleFillSymbol", "esri/SpatialReference", "esri/layers/GraphicsLayer", "dojo/on", "dojo/domReady!",
|
|
|
+ "esri/InfoTemplate","esri/geometry/Point", "esri/graphic"],
|
|
|
+ function (
|
|
|
+ MapControl, Color, SimpleMarkerSymbol, SimpleLineSymbol,
|
|
|
+ SimpleFillSymbol,SpatialReference, GraphicsLayer, on,
|
|
|
+ InfoTemplate, Point, Graphic) {
|
|
|
+ // 初始化地图对象
|
|
|
+ map = new MapControl(
|
|
|
+ "map",
|
|
|
+ {
|
|
|
+ minLevel: 1, // 地图可缩放的最小级别
|
|
|
+ maxLevel: 18, // 地图可缩放的最大级别
|
|
|
+ //xmin: 115.9652862549,// 地图默认初始化范围最小经度
|
|
|
+ //ymin: 39.9267988067,// 地图默认初始化范围最小纬度
|
|
|
+ //xmax: 116.4370117187,// 地图默认初始化范围最大经度
|
|
|
+ //ymax: 40.1822305621,// 地图默认初始化范围最大纬度
|
|
|
+ showLabels: false, // FeatureLayer是否支持标注
|
|
|
+ isMercator: true, // 地图是否采用Mercator坐标系
|
|
|
+ mustTile: true // 支持全球连续模式
|
|
|
+ });
|
|
|
+ console.log("MapControl",map.MainMap, map);
|
|
|
+
|
|
|
+ // 地图参数配置
|
|
|
+ mapConfig = {
|
|
|
+ MapName: "华北油田生产指挥平台",
|
|
|
+ Token: app.token,
|
|
|
+ MapUrl: "http://a4.petrochina/arcgis/rest/services/HBYTSCZHPT/MapServer"
|
|
|
+ // MapUrl: "https://10.188.246.122:8185/arcgis/rest/services/HBYTSCZHPT/MapServer" // 给厂家打包
|
|
|
+ };
|
|
|
+
|
|
|
+ // 底图服务地址
|
|
|
+ var tileUrlPre = "http://a4.petrochina/A4Service/TileService.ashx?c=${col}&r=${row}&l=${level}&token=" + mapConfig.Token + "&type=";
|
|
|
+ // var tileUrlPre = "https://10.188.246.122:8185/A4Service/TileService.ashx?c=${col}&r=${row}&l=${level}&token=" + mapConfig.Token + "&type="; // 给厂家打包
|
|
|
+
|
|
|
+ // 数字线划图
|
|
|
+ var dlg = new Object();
|
|
|
+ dlg.TileID = "DLG";
|
|
|
+ dlg.TileName = "数字线划图";
|
|
|
+ dlg.MinLevel = 1;
|
|
|
+ dlg.MaxLevel = 18;
|
|
|
+ dlg.Token = null;
|
|
|
+ dlg.UrlFormats = [];
|
|
|
+ dlg.UrlFormats.push(tileUrlPre + "VECMIX");
|
|
|
+
|
|
|
+ // 数字正射影像
|
|
|
+ var dom = new Object();
|
|
|
+ dom.TileID = "DOM";
|
|
|
+ dom.TileName = "数字正射影像";
|
|
|
+ dom.MinLevel = 1;
|
|
|
+ dom.MaxLevel = 18;
|
|
|
+ dom.Token = null;
|
|
|
+ dom.UrlFormats = [];
|
|
|
+ dom.UrlFormats.push(tileUrlPre + "TDTIMG");
|
|
|
+ dom.UrlFormats.push(tileUrlPre + "TDTCIA");
|
|
|
+
|
|
|
+ // 加载瓦片数据
|
|
|
+ var tileSetting = [dlg, dom];
|
|
|
+ map.LoadTiles(tileSetting, "DLG");
|
|
|
+
|
|
|
+ var depName = "采油一厂"; // 初始厂名:采油一厂、采油二厂、采油三厂、采油四厂、采油五厂、二连分公司
|
|
|
+ var layerFilter = getLayerFilter(depName); // 图层过滤条件
|
|
|
+
|
|
|
+ // AGSLayer添加前事件
|
|
|
+ on.once(map, "BeforeAddMap", function (evt) {
|
|
|
+ var filter = [];
|
|
|
+ for (var i = 0, c = evt.Layers.length; i < c; i++) {
|
|
|
+ filter.push({ LayerID: evt.Layers[i].id, Filter: layerFilter });
|
|
|
+ }
|
|
|
+ //evt.MapInfo.LayersFilter = filter;
|
|
|
+ });
|
|
|
+
|
|
|
+ map.MainMap.on("load", function (){
|
|
|
+ console.log("map.MainMap.on.load",arguments);
|
|
|
+ //添加一个图层,用户坐标点显示
|
|
|
+ graLayer = new GraphicsLayer();
|
|
|
+ map.MainMap._innerAddLayer(graLayer);
|
|
|
+
|
|
|
+ //通知父页面,加载完成
|
|
|
+ window.parent.postMessage({action:'test', message:'hello,我即将传给父项目'}, "*");
|
|
|
+ });
|
|
|
+ map.MainMap.on("click", function (event){
|
|
|
+ //testers.push({x:event.mapPoint2.x, y:event.mapPoint2.y});
|
|
|
+ //console.log("map.MainMap.on.click", JSON.stringify(testers));
|
|
|
+ });
|
|
|
+
|
|
|
+ // 图层初始化完成事件
|
|
|
+ on(map, "AGSLayerInited", function (agsLayer) {
|
|
|
+ locateByDepName(depName);
|
|
|
+ hideLayers();
|
|
|
+ // 创建空间引用
|
|
|
+ app.sr = new SpatialReference(4326);
|
|
|
+
|
|
|
+ //创建GraphicsLayer
|
|
|
+ app.graLayer = new GraphicsLayer();
|
|
|
+
|
|
|
+ //将GraphicsLayer添加到地图
|
|
|
+ map.AddLayer(app.graLayer);
|
|
|
+
|
|
|
+ // 地图级别更改事件
|
|
|
+ on(map, "MapLevelChanged", function (level) {
|
|
|
+ console.log('map1', map.GetLevel());
|
|
|
+ });
|
|
|
+ // 鼠标移入事件
|
|
|
+ app.graLayer.on("mouse-over", function (evt) {
|
|
|
+ map.MainMap.setMapCursor("pointer");
|
|
|
+ });
|
|
|
+
|
|
|
+ // 鼠标点击事件
|
|
|
+ app.graLayer.on("click", function (evt) {
|
|
|
+ console.log('e',evt);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 鼠标移出事件
|
|
|
+ app.graLayer.on("mouse-out", function (evt) {
|
|
|
+ map.MainMap.setMapCursor("default");
|
|
|
+ });
|
|
|
+
|
|
|
+ // 设置app参数
|
|
|
+ app.layer = findLayerByName("地面工程");
|
|
|
+ app.url = app.layer.MapServer + "?token=" + app.token;
|
|
|
+
|
|
|
+ // 创建符号
|
|
|
+ app.markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0, 1]), 1), new Color([255, 0, 0, 0.35]));
|
|
|
+ app.lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0, 1]), 1);
|
|
|
+ app.fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0, 0.65]), 1), new Color([255, 0, 0, 0.35]));
|
|
|
+ });
|
|
|
+ on(map, "GraphicMouseClick", function (evt) {
|
|
|
+ console.log('q', evt);
|
|
|
+ // 自定义window方法,vue组件注册,完成vue与iframe的通信,注册方法见baidu-page -> CenterCenter,搜索handleSpanClick
|
|
|
+ window.parent['handleSpanClick'](evt.name, evt.graphic.attributes);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 加载地图服务数据
|
|
|
+ map.AddMap(mapConfig);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 获取图层过滤条件
|
|
|
+ function getLayerFilter(depName) {
|
|
|
+ switch (depName) {
|
|
|
+ case "采油一厂":
|
|
|
+ return "SSDWDM BETWEEN 275964248064 AND 275964264447";
|
|
|
+ case "采油二厂":
|
|
|
+ return "SSDWDM BETWEEN 275964264448 AND 275964280831";
|
|
|
+ case "采油三厂":
|
|
|
+ return "SSDWDM BETWEEN 275964280832 AND 275964297215";
|
|
|
+ case "采油四厂":
|
|
|
+ return "SSDWDM BETWEEN 275964411904 AND 275964428287";
|
|
|
+ case "采油五厂":
|
|
|
+ return "SSDWDM BETWEEN 275964313600 AND 275964329983";
|
|
|
+ case "二连分公司":
|
|
|
+ return "SSDWDM BETWEEN 275964329984 AND 275964346367";
|
|
|
+ default:
|
|
|
+ return "1=1";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据厂名称定位
|
|
|
+ function locateByDepNameSelect() {
|
|
|
+ var depName = $('#company').prop('value')
|
|
|
+ var where = "ORG_NAME='" + depName + "'";
|
|
|
+ queryRecords("厂边界", where, ["OBJECTID", "ORG_NAME"], function (features) {
|
|
|
+ if (!features || !features.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var f = features[0];
|
|
|
+ var layer = findLayerByName("厂边界");
|
|
|
+ map.ZoomToGeometry(f.geometry, layer); // 定位
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据井名称定位
|
|
|
+ function locateByDepNameButton() {
|
|
|
+ var depName = $('#condition').val()
|
|
|
+ console.log(depName)
|
|
|
+ var where = "WELL_COMMON_NAME='" + depName + "'";
|
|
|
+ queryRecords("井", where, ["OBJECTID", "WELL_COMMON_NAME"], function (features) {
|
|
|
+ if (!features || !features.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var f = features[0];
|
|
|
+ var layer = findLayerByName("井");
|
|
|
+ map.ZoomToGeometry(f.geometry, layer); // 定位
|
|
|
+ map.Flash(f.geometry, { count: 5 }); // 闪烁要素
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function locateByDepName(depName) {
|
|
|
+ var where = "ORG_NAME='" + depName + "'";
|
|
|
+ queryRecords("厂边界", where, ["OBJECTID", "ORG_NAME"], function (features) {
|
|
|
+ if (!features || !features.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var f = features[0];
|
|
|
+ var layer = findLayerByName("厂边界");
|
|
|
+ map.ZoomToGeometry(f.geometry, layer); // 定位
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 查询并定位
|
|
|
+ function query() {
|
|
|
+ queryRecords("井", "WELL_COMMON_NAME='霸49'", ["OBJECTID", "WELL_COMMON_NAME"], function (features) {
|
|
|
+ if (!features || !features.length) {
|
|
|
+ alert("查询失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var f = features[0];
|
|
|
+ var layer = findLayerByName("井");
|
|
|
+ map.ZoomToGeometry(f.geometry, layer); // 定位
|
|
|
+ map.Flash(f.geometry, { count: 5 }); // 闪烁要素
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询记录
|
|
|
+ function queryRecords(layerName, where, fields, callback) {
|
|
|
+ require(["esri/tasks/query", "esri/tasks/QueryTask"], function (Query, QueryTask) {
|
|
|
+ var layer = findLayerByName(layerName);
|
|
|
+ var url = layer.MapServer + "?token=" + mapConfig.Token;
|
|
|
+
|
|
|
+ // 创建查询
|
|
|
+ var query = new Query();
|
|
|
+ query.returnGeometry = true; // 返回空间数据
|
|
|
+ query.where = where; // 查询条件
|
|
|
+ query.outFields = fields; // 返回字段
|
|
|
+ query.outSpatialReference = map.MainMap.spatialReference; // 返回数据的空间引用
|
|
|
+
|
|
|
+ // 创建查询任务
|
|
|
+ var task = new QueryTask(url);
|
|
|
+ task.execute(query, function (featureSet) {
|
|
|
+ if (callback) {
|
|
|
+ callback(featureSet && featureSet.features ? featureSet.features : null);
|
|
|
+ }
|
|
|
+ }, function (err) {
|
|
|
+ // 查询出错
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据图层名称查找图层
|
|
|
+ function findLayerByName(layerName) {
|
|
|
+ var agsLayers = map.GetAllAGSLayers();
|
|
|
+
|
|
|
+ var layers = agsLayers[0];
|
|
|
+ for (var i = 0, c = layers.MapServerLayers.length; i < c; i++) {
|
|
|
+ if (layers.MapServerLayers[i].name == layerName) {
|
|
|
+ return layers.MapServerLayers[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示井图层
|
|
|
+ function showLayers() {
|
|
|
+ // var all = ["井", "煤层气井",
|
|
|
+ // "变电所", "联合站", "处理厂", "接转站", "脱水站", "增压站", "卸油站", "计量站(间)", "集油阀组间", "采油站",
|
|
|
+ // "井网管道-油", "站间管道-油", "外输管线-油", "掺稀油管道",
|
|
|
+ // "站库面", "配电线",
|
|
|
+ // "厂边界", "矿边界"];
|
|
|
+ if ($('#well').prop('checked') === true) {
|
|
|
+ var layerNames = ["采油井"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+ if ($('#well').prop('checked') === false) {
|
|
|
+ var layerNames = ["采油井"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ }
|
|
|
+ // var layerNames = ["井", "煤层气井"];
|
|
|
+ // setLayerVisible(layerNames, true);
|
|
|
+ // setLayerVisible(all, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示站图层
|
|
|
+ function showStationLayers() {
|
|
|
+ if ($('#station').prop('checked') === true) {
|
|
|
+ var layerNames = ["联合站", "接转站", "脱水站", "增压站", "卸油站", "计量站(间)", "集油阀组间", "采油站"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ console.log('1')
|
|
|
+ }
|
|
|
+ if ($('#station').prop('checked') === false) {
|
|
|
+ var layerNames = ["联合站", "接转站", "脱水站", "增压站", "卸油站", "计量站(间)", "集油阀组间", "采油站"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ console.log('2')
|
|
|
+ }
|
|
|
+ // var layerNames = ["井", "煤层气井"];
|
|
|
+ // setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示管道图层
|
|
|
+ function showPipeLayers() {
|
|
|
+ if ($('#pipe').prop('checked') === true) {
|
|
|
+ var layerNames = ["井网管道-油", "站间管道-油", "外输管线-油", "掺稀油管道"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+ if ($('#pipe').prop('checked') === false) {
|
|
|
+ var layerNames = ["井网管道-油", "站间管道-油", "外输管线-油", "掺稀油管道"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ }
|
|
|
+ // var layerNames = ["井", "煤层气井"];
|
|
|
+ // setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示地质单元图层
|
|
|
+ function showGeologyLayers() {
|
|
|
+ if ($('#geology').prop('checked') === true) {
|
|
|
+ var layerNames = ["矿边界"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+ if ($('#geology').prop('checked') === false) {
|
|
|
+ var layerNames = ["矿边界"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示厂图层
|
|
|
+ function showFactoryLayers() {
|
|
|
+ if ($('#factory').prop('checked') === true) {
|
|
|
+ var layerNames = ["厂边界"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+ if ($('#factory').prop('checked') === false) {
|
|
|
+ var layerNames = ["厂边界"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ }
|
|
|
+ // var layerNames = ["井", "煤层气井"];
|
|
|
+ // setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示电力单元图层
|
|
|
+ function showPowerLayers() {
|
|
|
+ if ($('#power').prop('checked') === true) {
|
|
|
+ var layerNames = ["站库面", "配电线"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ console.log('1')
|
|
|
+ }
|
|
|
+ if ($('#power').prop('checked') === false) {
|
|
|
+ var layerNames = ["站库面", "配电线"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ console.log('2')
|
|
|
+ }
|
|
|
+ // var layerNames = ["井", "煤层气井"];
|
|
|
+ // setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+ // 显示矿权单元图层
|
|
|
+ function showKQLayers() {
|
|
|
+ console.log('zzz', map.GetLevel());
|
|
|
+ if ($('#kq').prop('checked') === true) {
|
|
|
+ var layerNames = ["矿权"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ console.log('1')
|
|
|
+ }
|
|
|
+ if ($('#kq').prop('checked') === false) {
|
|
|
+ var layerNames = ["矿权"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ console.log('2')
|
|
|
+ }
|
|
|
+ // var layerNames = ["井", "煤层气井"];
|
|
|
+ // setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+ // 显示矿权单元图层
|
|
|
+ function showCity() {
|
|
|
+ console.log('zzz', map.GetLevel());
|
|
|
+ if ($('#ct').prop('checked') === true) {
|
|
|
+ var layerNames = ["省级行政区"];
|
|
|
+ setLayerVisible(layerNames, true);
|
|
|
+ console.log('1')
|
|
|
+ }
|
|
|
+ if ($('#ct').prop('checked') === false) {
|
|
|
+ var layerNames = ["省级行政区"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ console.log('2')
|
|
|
+ }
|
|
|
+ // var layerNames = ["井", "煤层气井"];
|
|
|
+ // setLayerVisible(layerNames, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 隐藏图层
|
|
|
+ function hideLayers() {
|
|
|
+ var layerNames = ["矿权"];
|
|
|
+ setLayerVisible(layerNames, false);
|
|
|
+ }
|
|
|
+ // 设置图层显示
|
|
|
+ function setLayerVisible(layerNames, flag) {
|
|
|
+ console.log('layerNames', layerNames);
|
|
|
+ var ids = [];
|
|
|
+ for (var i = 0, c = layerNames.length; i < c; i++) {
|
|
|
+ var layer = findLayerByName(layerNames[i]);
|
|
|
+ if (layer) {
|
|
|
+ ids.push(layer.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var agsLayer = map.GetAllAGSLayers()[0];
|
|
|
+ agsLayer.SetVisibilityEx(ids, flag);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 切换底图按钮
|
|
|
+ function changeTile() {
|
|
|
+ var ts = map.GetCurrentTileSetting();
|
|
|
+ var tid = ts.TileID == "DLG" ? "DOM" : "DLG";
|
|
|
+ map.ChangeTile(tid);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 切换底图下拉菜单
|
|
|
+ function typeChange() {
|
|
|
+ var ts = map.GetCurrentTileSetting();
|
|
|
+ var myItem = document.getElementById("sel");
|
|
|
+ var myOption = myItem.options[myItem.selectedIndex].getAttribute('on');
|
|
|
+ //根据获取到的不同属性值,来指定不同事件
|
|
|
+ if(myOption == '1'){
|
|
|
+ map.ChangeTile("DLG");
|
|
|
+ }
|
|
|
+ if(myOption == '2'){
|
|
|
+ map.ChangeTile("DOM");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点查
|
|
|
+ function drawPoint() {
|
|
|
+ cls();
|
|
|
+ map.DrawPoint(function (e) {
|
|
|
+ queryRecords1(e.geometry);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 线查
|
|
|
+ function drawLine() {
|
|
|
+ cls();
|
|
|
+ map.DrawPolyline(function (e) {
|
|
|
+ console.log('线查DrawPolyline方法的参数', e);
|
|
|
+ queryRecords1(e.geometry);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 圆查
|
|
|
+ function drawCircle() {
|
|
|
+ cls();
|
|
|
+ map.DrawCircle(function (e) {
|
|
|
+ console.log('2', e);
|
|
|
+ queryRecords1(e.geometry);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 面查
|
|
|
+ function drawPolygon() {
|
|
|
+ cls();
|
|
|
+ map.DrawPolygon(function (e) {
|
|
|
+ queryRecords1(e.geometry);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 框查
|
|
|
+ function drawRect() {
|
|
|
+ cls();
|
|
|
+ map.DrawRect(function (e) {
|
|
|
+ queryRecords1(e.geometry);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 查询记录
|
|
|
+ function queryRecords1(geometry) {
|
|
|
+ map.Pan(); // 地图平移
|
|
|
+ addGraphic(geometry); // 添加图形
|
|
|
+
|
|
|
+ require(["esri/tasks/query", "esri/tasks/QueryTask"], function (Query, QueryTask) {
|
|
|
+ // 创建查询
|
|
|
+ var query = new Query();
|
|
|
+ query.geometry = geometry; // 空间条件
|
|
|
+ query.returnGeometry = true; // 返回空间数据 ,
|
|
|
+ // query.outFields = ["OBJECTID", "WELL_COMMON_NAME", "WELL_LEGAL_NAME", "WELL_PURPOSE",]; // 返回字段
|
|
|
+ query.outFields = ["*"]; // 返回字段
|
|
|
+ query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS; // 交集
|
|
|
+ query.outSpatialReference = map.MainMap.spatialReference; // 返回数据的空间引用
|
|
|
+
|
|
|
+ // 对点进行100米缓冲,避免查无数据
|
|
|
+ if (geometry.type == "point" || geometry.type == 'polyline') {
|
|
|
+ query.units = "meters"; // 单位
|
|
|
+ query.distance = 500; // 距离
|
|
|
+ }
|
|
|
+ // 创建查询任务
|
|
|
+ // app.layerStation = findLayerByName("站库面",);
|
|
|
+ app.layerStation = findLayerByName("集油_中型站库",);
|
|
|
+ app.urlStation = app.layerStation.MapServer + "?token=" + app.token;
|
|
|
+
|
|
|
+ app.layerStation3 = findLayerByName("集油_大型站库",);
|
|
|
+ app.urlStation3 = app.layerStation3.MapServer + "?token=" + app.token;
|
|
|
+
|
|
|
+ app.layerStation4 = findLayerByName("集油_小型站库",);
|
|
|
+ app.urlStation4 = app.layerStation4.MapServer + "?token=" + app.token;
|
|
|
+
|
|
|
+ app.layerWell = findLayerByName("采油井",);
|
|
|
+ app.urlWell = app.layerWell.MapServer + "?token=" + app.token;
|
|
|
+
|
|
|
+ var task = new QueryTask(app.urlStation); // 站
|
|
|
+ var task3 = new QueryTask(app.urlStation3); // 站
|
|
|
+ var task4 = new QueryTask(app.urlStation4); // 站
|
|
|
+ var task2 = new QueryTask(app.urlWell); // 井
|
|
|
+
|
|
|
+ task.execute(query, queryCallBack, function (err) {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ task2.execute(query, queryCallBack, function (err) {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ task3.execute(query, queryCallBack, function (err) {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ task4.execute(query, queryCallBack, function (err) {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询回调函数
|
|
|
+ function queryCallBack(featureSet) {
|
|
|
+ console.log('queryCallBack查询图层数据(采油井)', featureSet.features)
|
|
|
+ var count = featureSet && featureSet.features.length ? featureSet.features.length : 0;
|
|
|
+ $("#info").html("查询到 " + count + " 条记录<br/>");
|
|
|
+ // if (count == 0) {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ window.parent['drawCircleClick'](featureSet.features);
|
|
|
+ // 输出记录
|
|
|
+ // for (var i = 0; i < count; i++) {
|
|
|
+ // var f = featureSet.features[i];
|
|
|
+ // var html = "<span id='f_" + f.attributes["OBJECTID"] + "'>" + (i + 1) + " > " + f.attributes["WELL_COMMON_NAME"] + "</span><br/>";
|
|
|
+ // $("#info").append(html);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 绑定定位功能
|
|
|
+ $("#info span").on("click", function (e) {
|
|
|
+ var id = $(this).attr("id").replace("f_", "");
|
|
|
+ for (var i = 0; i < count; i++) {
|
|
|
+ var f = featureSet.features[i];
|
|
|
+ if (f.attributes["OBJECTID"] == id) {
|
|
|
+ map.ZoomToGeometry(f.geometry, app.layer); // 定位
|
|
|
+ map.Flash(f.geometry, { count: 5 }); // 闪烁要素
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清除
|
|
|
+ function cls(type) {
|
|
|
+ // document.getElementById("long").value = '';
|
|
|
+ // document.getElementById("lat").value = '';
|
|
|
+ // 清除
|
|
|
+ app.graLayer.clear();
|
|
|
+ map.ClearGraphic();
|
|
|
+ if (type) {
|
|
|
+ $("#info").html("提示:对“华北油田-井”图层进行查询。");
|
|
|
+ } else {
|
|
|
+ $("#info").html("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //显示定位图标
|
|
|
+ var pgs = {};
|
|
|
+ var pointObjects = {};
|
|
|
+ function setSymbols(points) {
|
|
|
+ graLayer.clear();
|
|
|
+ pgs = {};
|
|
|
+ pointObjects = {};
|
|
|
+
|
|
|
+ require(["esri/geometry/Point", "esri/graphic", "esri/Color", "esri/symbols/SimpleMarkerSymbol", "esri/InfoTemplate"],
|
|
|
+ function (Point, Graphic, Color, SimpleMarkerSymbol, InfoTemplate) {
|
|
|
+ let minx=points[0].x, maxx=points[0].x;
|
|
|
+ let miny=points[0].y, maxy=points[0].y;
|
|
|
+
|
|
|
+ //显示所有标注
|
|
|
+ for(let i=0;i<points.length;i++) {
|
|
|
+ let obj = points[i];
|
|
|
+ if(obj.x==null || obj.x==undefined) continue;
|
|
|
+ if(obj.y==null || obj.y==undefined) continue;
|
|
|
+ obj.x = obj.x *1;
|
|
|
+ obj.y = obj.y *1;
|
|
|
+
|
|
|
+ let point = new Point(obj.x, obj.y, app.sr);
|
|
|
+ let pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,
|
|
|
+ 12, null, new Color([255, 0, 0, 1]));
|
|
|
+
|
|
|
+ let template = new InfoTemplate();
|
|
|
+ template.setTitle("<b>${well_id}</b>");
|
|
|
+ template.setContent("井名:${well_common_name}<br>地址:${geo_description}");
|
|
|
+
|
|
|
+ obj.index = i;
|
|
|
+ var pg = new Graphic(point, pointSymbol, obj, template);
|
|
|
+ // 添加图形到GraphicsLayer
|
|
|
+ graLayer.add(pg);
|
|
|
+ pgs[obj.well_id] = pg;
|
|
|
+ pointObjects[obj.well_id] = point;
|
|
|
+
|
|
|
+ if(obj.x < minx) minx = obj.x;
|
|
|
+ if(obj.x > maxx) maxx = obj.x;
|
|
|
+ if(obj.y < miny) miny = obj.y;
|
|
|
+ if(obj.y > maxy) maxy = obj.y;
|
|
|
+ }
|
|
|
+ //地图放大缩小
|
|
|
+ let border = 0.3;
|
|
|
+ console.log("max min", minx, miny, maxx, maxy);
|
|
|
+ minx = minx*1 - border;
|
|
|
+ miny = miny*1 - border;
|
|
|
+ maxx = maxx*1 + border;
|
|
|
+ maxy = maxy*1 + border;
|
|
|
+ console.log("max min", minx, miny, maxx, maxy);
|
|
|
+ map.ZoomToExtent(minx, miny, maxx, maxy);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function clearSymbols(){
|
|
|
+ graLayer.clear();
|
|
|
+ let long = document.getElementById("long").value;
|
|
|
+ let lat = document.getElementById("lat").value;
|
|
|
+ map.ZoomToLevel(9, long, lat);
|
|
|
+ }
|
|
|
+
|
|
|
+ function zoomToCenter(obj){
|
|
|
+ if(obj.x==null || obj.x==undefined) return;
|
|
|
+ if(obj.y==null || obj.y==undefined) return;
|
|
|
+ obj.x = obj.x *1;
|
|
|
+ obj.y = obj.y *1;
|
|
|
+
|
|
|
+ //map.ZoomToLevel(9, obj.x, obj.y);
|
|
|
+
|
|
|
+ if(pointObjects[obj.well_id]) {
|
|
|
+ console.log("zoomToCenter",pointObjects[obj.well_id]);
|
|
|
+ // 设置弹窗自动显示
|
|
|
+ map.MainMap.infoWindow.show(pointObjects[obj.well_id]);
|
|
|
+ map.MainMap.infoWindow.setFeatures([pgs[obj.well_id]]);
|
|
|
+ map.MainMap.centerAt(pointObjects[obj.well_id]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获得vue iframe 传过来的数据
|
|
|
+ window.addEventListener("message", function (event) {
|
|
|
+ console.log('child handle Message', event);
|
|
|
+ if(event.data.action=="setSymbols"){
|
|
|
+ let points = JSON.parse(event.data.datas);
|
|
|
+ console.log('child handle points', points);
|
|
|
+ setSymbols(points);
|
|
|
+ }
|
|
|
+ if(event.data.action=="setCenter"){
|
|
|
+ let point = JSON.parse(event.data.item);
|
|
|
+ zoomToCenter(point);
|
|
|
+ }
|
|
|
+ }, false);
|
|
|
+ </script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+<div id="map"></div>
|
|
|
+<div id="poiSearch"></div>
|
|
|
+<div id="ctrl" style="display: inline-block;">
|
|
|
+ <div class="option">
|
|
|
+ <select id="company" name="company" onchange="locateByDepNameSelect();">
|
|
|
+ <option value='' disabled selected style='display:none; color: gray'>请选择生产单位</option>
|
|
|
+ <option on="1" value="采油一厂">采油一厂</option>
|
|
|
+ <option on="2" value="采油二厂">采油二厂</option>
|
|
|
+ <option on="3" value="采油三厂">采油三厂</option>
|
|
|
+ <option on="4" value="采油四厂">采油四厂</option>
|
|
|
+ <option on="5" value="采油五厂">采油五厂</option>
|
|
|
+ <option on="6" value="二连分公司">二连分公司</option>
|
|
|
+ <option on="7" value="巴彦分公司">巴彦分公司</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="option">
|
|
|
+ <select id="sel" name="selectType" onchange="typeChange()">
|
|
|
+ <option value='' disabled selected style='display:none;'>请选择底图影像</option>
|
|
|
+ <option on="1" value="DLG">数字线划图</option>
|
|
|
+ <option on="2" value=“DOM”>数字正射影像</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+</body>
|
|
|
+</html>
|