6bd42bcd4b2205f3f3e5330b38c75b3a1b7efc59.svn-base 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div id="mapContent" style="height:100%;" v-loading="loading">
  3. <!-- 地图容器 -->
  4. <div id="mapNode" style="width:100%;height:100%;"></div>
  5. <!-- 地图小工具 -->
  6. <div style="position: absolute;right: 20px;top: 106px;">
  7. <el-radio-group v-model="radio4" size="mini" @change="baseMapChange">
  8. <el-radio-button label="影像"></el-radio-button>
  9. <!-- <el-radio-button label="矢量" disabled></el-radio-button> -->
  10. <!-- <el-radio-button label="地形"></el-radio-button> -->
  11. <el-radio-button label="谷歌"></el-radio-button>
  12. <el-radio-button label="高德"></el-radio-button>
  13. </el-radio-group>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. const options = {
  19. url: "/arcgisApi/4.7/init.js"
  20. };
  21. import Vue from 'vue'
  22. import * as esriLoader from 'esri-loader'
  23. import request from "../../utils/gw_ajax_request.js"
  24. import {dateFormat} from "../../utils/gw_date.js"
  25. //config
  26. import {baseLayerOptions,baseLayerOptions_M,gaodeTileInfo} from '../../views/zongHeXinXiNew/config/lyrConfig.js'
  27. //handler
  28. import {baseMapChangeHandler} from '../../views/zongHeXinXiNew/js/baseMapChange.js' //底图切换
  29. export default {
  30. components:{
  31. },
  32. props:['gdX','gdY'],
  33. computed:{
  34. userId: function () {
  35. return localStorage.getItem("userid") ?localStorage.getItem("userid") : "1098101939614724096";
  36. },
  37. },
  38. data(){
  39. return {
  40. loading:true,
  41. radio4:'影像',//底图切换radiobutton
  42. mapObject:null,
  43. viewObject:null,
  44. fullExtent:'',
  45. initOptions:null,//各图层option
  46. popupDelay:'',//延时弹出
  47. currentRsCode:'1111111',
  48. currentStatus:'',
  49. currentLocation:'',
  50. zoomnext:'',
  51. currentExtent:'',
  52. timeInterval_people:'',//定时刷新人员
  53. currentChangeGraphicLayerId:'',//当前graphic类型变化的图层id
  54. currentChangeGraphicId:'',
  55. tileInfo:'',//高德切片信息
  56. biaojiFlag:false,
  57. showBiaojiTable:false,
  58. activeName:'到这去',
  59. currentAdCode:'',
  60. leftLayersAddedList:[],//左侧图层已经添加列表 为一张图查询做支撑
  61. showSearchOneMapToolTip:false,//一张图查询开关
  62. showSearchOneMap:false,//一张图空间查询结果
  63. mapPointObj:null,
  64. bufferDistance1:10,//缓冲距离
  65. showRealTimeData:false,//水利一张图实时数据查询列表
  66. }
  67. },
  68. watch:{
  69. },
  70. mounted(){
  71. this.initOptions = baseLayerOptions_M;
  72. this.tileInfo = gaodeTileInfo;
  73. this.initMap();
  74. },
  75. methods:{
  76. initMap(){//初始化地图
  77. var _self = this;
  78. esriLoader.loadModules(["esri/Map","esri/views/MapView","esri/geometry/SpatialReference",
  79. "esri/geometry/Extent","esri/layers/MapImageLayer","esri/Basemap","esri/layers/tdtLayer",
  80. 'esri/layers/WebTileLayer','esri/layers/support/TileInfo',
  81. "esri/geometry/Point","esri/config","dojo/domReady!"],options).then( (
  82. [Map,MapView,SpatialReference,Extent,MapImageLayer,Basemap,tdtLayer,WebTileLayer, TileInfo,
  83. Point,esriConfig,]) => {
  84. _self.mapObject = new Map({});
  85. for(var i=0;i<_self.initOptions.length;i++){//加载底图服务
  86. if(_self.initOptions[i].id == "id_gaode"){
  87. var tileInfo1 = new TileInfo(this.tileInfo);
  88. var gaodelayer = WebTileLayer(_self.initOptions[i].urlTemplate, {
  89. tileInfo:tileInfo1,
  90. id:_self.initOptions[i].id,
  91. visible:_self.initOptions[i].visible
  92. })
  93. _self.mapObject.add(gaodelayer);
  94. }else if(_self.initOptions[i].id == "id_google"){
  95. var lyr = new WebTileLayer({
  96. urlTemplate:_self.initOptions[i].urlTemplate,
  97. id:_self.initOptions[i].id,
  98. subDomains:_self.initOptions[i].subDomains,
  99. visible:_self.initOptions[i].visible
  100. });
  101. _self.mapObject.add(lyr);
  102. }else{
  103. var lyr = new WebTileLayer({
  104. urlTemplate:_self.initOptions[i].urlTemplate,
  105. id:_self.initOptions[i].id,
  106. subDomains:_self.initOptions[i].subDomains,
  107. visible:_self.initOptions[i].visible
  108. });
  109. _self.mapObject.add(lyr);
  110. }
  111. }
  112. _self.viewObject = new MapView({
  113. container: "mapNode",
  114. map: _self.mapObject,
  115. viewingMode: "global",
  116. constraints:{
  117. rotationEnabled: false
  118. }
  119. });
  120. _self.viewObject.ui.move([ "zoom" ], "bottom-right");
  121. _self.viewObject.when(function(){
  122. var ext = new Extent({
  123. xmax: 15979347.376847023,
  124. xmin: 7628754.910750309,
  125. ymax: 6006251.7894124305,
  126. ymin: 2518277.3147041956,
  127. spatialReference: new SpatialReference({wkid:102100})
  128. });
  129. _self.viewObject.extent = ext;
  130. _self.fullExtent = ext;
  131. _self.loading = false;
  132. _self.locationHandler(_self.gdX,_self.gdY)
  133. },function(error){
  134. console.log("The view's resources failed to load: ", error);
  135. });
  136. }).catch(err => {
  137. console.error(err);
  138. });
  139. },
  140. locationHandler(x,y,imgUrl){
  141. var _self = this;
  142. _self.viewObject.graphics.removeAll();
  143. esriLoader.loadModules(["esri/Graphic","esri/layers/GraphicsLayer",
  144. "esri/geometry/Point","esri/geometry/SpatialReference"],options).then(
  145. ([Graphic,GraphicsLayer,Point,SpatialReference])=>{
  146. var pt = new Point(x,y,new SpatialReference(4326));
  147. if(!imgUrl){
  148. var symbol = {
  149. type: "picture-marker",
  150. url: '/src/static/location.png',
  151. width: "36px",
  152. height: "36px"
  153. };
  154. var gra = new Graphic({
  155. geometry:pt,
  156. symbol:symbol,
  157. attributes:{}
  158. });
  159. _self.viewObject.graphics.add(gra);
  160. }else{
  161. var symbol = {
  162. type: "picture-marker",
  163. url: imgUrl,
  164. width: "12px",
  165. height: "12px"
  166. };
  167. var gra = new Graphic({
  168. geometry:pt,
  169. symbol:symbol,
  170. attributes:{}
  171. });
  172. _self.viewObject.graphics.add(gra);
  173. }
  174. _self.viewObject.goTo({
  175. target:pt,
  176. zoom:12
  177. }).then((info)=>{
  178. })
  179. });
  180. },
  181. baseMapChange(val){//底图切换
  182. this.viewObject.popup.close();
  183. baseMapChangeHandler(this.mapObject,val);
  184. },
  185. }
  186. }
  187. </script>
  188. <style>
  189. @import url('/arcgisApi/4.7/esri/css/main.css');
  190. /*屏蔽esri标注*/
  191. .esri-ui .esri-attribution{
  192. display: none;
  193. }
  194. #mapContent .esri-ui .esri-popup{
  195. z-index: 11111;
  196. }
  197. #mapContent .esri-ui-top-left esri-ui-corner{
  198. padding-left: 14%;
  199. }
  200. #mapContent .esri-view-width-xlarge .esri-popup__main-container{
  201. width: 310px;
  202. border-radius: 5px;
  203. /* background-color: #e2e7f1e6; */
  204. background-color: #ffffffe6;
  205. max-height: 300px;
  206. }
  207. #mapContent .esri-popup__button--dock{
  208. display: none;
  209. }
  210. #mapContent .esri-popup__feature-buttons, .esri-popup__feature-buttons [role="button"]{
  211. display: none;
  212. }
  213. #mapContent .esri-popup__content{
  214. font-size: 14px;
  215. line-height: 25px;
  216. overflow-y: hidden;
  217. }
  218. #mapContent .esri-popup__position-container{
  219. border-radius: 13px;
  220. }
  221. #mapContent .esri-popup__header{
  222. /* background-color: #a2cae8; */
  223. background-color:#2a67df59;
  224. border-top-left-radius: 5px;
  225. border-top-right-radius: 5px;
  226. height: 32px;
  227. }
  228. #mapContent .esri-popup--aligned-top-center .esri-popup__pointer-direction{
  229. background-color: #e2e7f1bf;
  230. }
  231. #mapContent .esri-popup--aligned-bottom-center .esri-popup__pointer-direction{
  232. background-color: #e2e7f1bf;
  233. }
  234. #mapContent .esri-widget table tr td, .esri-widget table tr th{
  235. padding: 0px;
  236. width: 50%;
  237. }
  238. #mapContent tr:nth-child(odd){
  239. background-color: rgba(76,76,76,0.1);
  240. }
  241. #mapContent .esri-popup__header {
  242. position: relative;
  243. font-size: 12px;
  244. align-items: center;
  245. justify-content: space-between;
  246. display: flex;
  247. flex: 0 0 auto;
  248. }
  249. .esri-basemap-gallery__item-thumbnail{
  250. height: 60px;
  251. width: 80px;
  252. }
  253. </style>