通过给地图绑定缩放,单击和平移命令,实现在地图附加div标签,实现infowindow效果;

  1. /*
  2. *作者 扰扰
  3. *自定义esri弹窗
  4. *paramter Map地图对象
  5. *paramter x
  6. *paramter y
  7. *paramter title标题
  8. *paramter html展示内容html字符串
  9. *paramter height弹窗高度默认为300
  10. *paramter width弹窗宽度默认为200
  11. */
  12. RaoRao.esriDivPanel = function (Map, x, y, title, html, height, width) {
  13. //加载时地图坐标
  14. var X = x, Y = y, map = Map;
  15. //弹窗宽度
  16. var Heigth = 300;
  17. if (height) { Height = height }
  18. //弹窗高度
  19. var Width = 400;
  20. if (width) { Width = width }
  21. //弹窗位置
  22. var top = 0;
  23. //弹窗位置
  24. var left = 0;
  25. //弹窗对象
  26. var Div = null;
  27. //移动量
  28. var movX = 0, movY = 0;
  29. //变化量
  30. var tempX = 0, tempY = 0;
  31. //地图拖拽事件
  32. this._panEvt = null;
  33. this._panEndEvt = null;
  34. //地图所缩放事件
  35. this._zoomStartEvt = null;
  36. this._zoomEndEvt = null;
  37. //弹窗DIV
  38. this.div = document.createElement("div");
  39. Div = this.div;
  40. this.div.className = "esriDivPanel";
  41. var divcss = 'width:' + Width + 'px;height:' + Heigth + 'px;';
  42. this.div.style.cssText = divcss;
  43.  
  44. this.title = document.createElement("div");
  45. this.title.className = "esriDivPanel_title";
  46. var close = document.createElement("div");
  47. close.className = "esriDivPanel_titleClose";
  48. close.innerHTML = "<span></span>";
  49.  
  50. var titletext = document.createElement("div");
  51. titletext.className = "esriDivPanel_titleTxt";
  52. titletext.innerHTML = title;
  53.  
  54. this.content = document.createElement("div");
  55. this.content.className = "esriDivPanel_content";
  56. this.content.innerHTML = html;
  57. this.content.style.cssText = "height:" + (Heigth - 32) + "px;";
  58.  
  59. this.triangle = document.createElement("div");
  60. this.triangle.className = "esriDivPanel_triangle";
  61.  
  62. this.title.appendChild(close);
  63. this.title.appendChild(titletext);
  64.  
  65. this.div.appendChild(this.title);
  66. this.div.appendChild(this.content);
  67. this.div.appendChild(this.triangle);
  68.  
  69. var point = new esri.geometry.Point(x, y, map.spatialReference);
  70. var p = map.toScreen(point);
  71. top = p.y - Heigth-36;
  72. left = p.x - Width / 2;
  73. this.div.style.top = top + "px";
  74. this.div.style.left = left + "px";
  75. document.getElementById(map.id).appendChild(this.div);
  76. //定义地图缩放事件
  77. this._zoomStartEvt = map.on("zoom-start", function (evt) {
  78. //Div.style.display = "none";
  79. var point = new esri.geometry.Point(X, Y, map.spatialReference);
  80. var p = map.toScreen(point);
  81. top = p.y - Heigth - 36;
  82. left = p.x - Width / 2;
  83. Div.style.top = top + "px";
  84. Div.style.left = left + "px";
  85. });
  86. this._zoomEndEvt = map.on("zoom-end", function (evt) {
  87. //Div.style.display = "block";
  88. var point = new esri.geometry.Point(X, Y, map.spatialReference);
  89. var p = map.toScreen(point);
  90. top = p.y - Heigth - 36;
  91. left = p.x - Width / 2;;
  92. Div.style.top = top + "px";
  93. Div.style.left = left + "px";
  94. });
  95. //定义地图拖拽事件
  96. this._panEvt = map.on("pan", function (evt) {
  97. var point = evt.delta;
  98. movX = point.x - tempX;
  99. movY = point.y - tempY;
  100. tempX = point.x; tempY = point.y;
  101. top = top + movY;
  102. left = left + movX;
  103. Div.style.top = top + "px";
  104. Div.style.left = left + "px";
  105. });
  106. this._panEndEvt = map.on("pan-end", function (evt) {
  107. tempX = 0;
  108. tempY = 0;
  109. });
  110. //定义关闭事件
  111. close.onclick = function () {
  112. if (this._panEndEvt) {
  113. this._panEndEvt.remove();
  114. }
  115. if (this._panEvt) {
  116. this._panEvt.remove();
  117. }
  118. if (this._zoomEndEvt) {
  119. this._zoomEndEvt.remove();
  120. }
  121. if (this._zoomStartEvt) {
  122. this._zoomStartEvt.remove();
  123. }
  124. this._panEndEvt = null;
  125. this._panEvt = null;
  126. this._zoomEndEvt = null;
  127. this._zoomStartEvt = null;
  128. document.getElementById(map.id).removeChild(Div);
  129. }
  130. }
  1. .esriDivPanel {
  2. position: absolute;
  3. z-index:;
  4. }
  5.  
  6. .esriDivPanel_title {
  7. border: 2px solid #333;
  8. height: 32px;
  9. width: 100%;
  10. background-color: #333;
  11. border-radius: 5px 5px 0px 0px;
  12. }
  13.  
  14. .esriDivPanel_titleClose {
  15. float: right;
  16. width: 24px;
  17. height: 24px;
  18. margin: 5px;
  19. }
  20.  
  21. .esriDivPanel_titleClose span {
  22. display: inline-block;
  23. width: 100%;
  24. height: 100%;
  25. text-align: center;
  26. overflow: hidden;
  27. position: relative;
  28. }
  29.  
  30. .esriDivPanel_titleClose span:hover {
  31. background-color: slategrey;
  32. }
  33.  
  34. .esriDivPanel_titleClose span::before, .esriDivPanel_titleClose span::after {
  35. position: absolute;
  36. content: '';
  37. top: 50%;
  38. left:;
  39. margin-top: -1px;
  40. background-color: #fff;
  41. width: 100%;
  42. height: 3px;
  43. }
  44.  
  45. .esriDivPanel_titleClose span::before {
  46. -webkit-transform: rotate(45deg);
  47. -moz-transform: rotate(45deg);
  48. }
  49.  
  50. .esriDivPanel_titleClose span::after {
  51. -webkit-transform: rotate(-45deg);
  52. -moz-transform: rotate(-45deg);
  53. }
  54.  
  55. .esriDivPanel_titleTxt {
  56. overflow: hidden;
  57. width: 75%;
  58. height: 32px;
  59. line-height: 32px;
  60. margin-left: 5px;
  61. color: white;
  62. }
  63.  
  64. .esriDivPanel_content {
  65. width: 100%;
  66. border: 2px solid #8c9794;
  67. background-color: #f8f8f8;
  68. overflow: hidden;
  69. }
  70.  
  71. .esriDivPanel_triangle {
  72. width: 0px;
  73. height: 0px;
  74. margin-left: 50%;
  75. /* background-color: #8c9794; */
  76. border-top: 20px solid #333;
  77. /* border-bottom: 20px solid rgba(140, 151, 148, 0.57); */
  78. border-right: 40px solid rgba(140, 151, 148, 0);
  79. border-left: 0px solid rgba(140, 151, 148, 0.26);
  80. }

再系统中引用代码就可以直接调用

通过div实现arcgis自定义infowindow的更多相关文章

  1. lzugis——Arcgis Server for JavaScript API之自定义InfoWindow(续)

    同样的标题后面加了一个括弧,不是为了增减博文数量,而确实是上个功能的完善,标注为续,意思是继续上次的内容,来说说如何自定义InfoWindow. 在上一讲中,实现了InfoWindow的显示,但是并没 ...

  2. ArcGIS自定义脚本-通过txt/excel/dbf/table生成多边形要素类

    ArcGIS自定义脚本-通过txt/excel/dbf/table生成多边形要素类 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:读取文本文件,常见多边形要素 ...

  3. ArcGIS自定义工具箱-列举损坏的数据源

    ArcGIS自定义工具箱-列举损坏的数据源 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:查找地图文档中损坏的数据源链接 使用方法:参数可选,默认为当前(ar ...

  4. ArcGIS自定义工具箱-修复损坏的工作空间

    ArcGIS自定义工具箱-修复损坏的工作空间 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:替换数据源的工作空间 用途:针对损坏的数据源,批量进行修复 案例数 ...

  5. ArcGIS自定义工具箱-显示地图文档结构

    ArcGIS自定义工具箱-显示地图文档结构 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:显示地图文档mxd的数据组织结构,数据框,图层,表 使用方法: 地图 ...

  6. ArcGIS自定义工具箱-清空工作空间

    ArcGIS自定义工具箱-清空工作空间 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:删除工作空间里的要素类,栅格和独立表 使用方法: 例如"C:\ ...

  7. ArcGIS自定义工具箱-字段合并

    ArcGIS自定义工具箱-字段合并 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:用指定字符合并两个字段 用例:湖南/长沙=>湖南省长沙市 数据源: 使 ...

  8. ArcGIS自定义工具箱-字段分割

    ArcGIS自定义工具箱-字段分割 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:用指定分割符分割字段, 用例:湖南省长沙市=>湖南/长沙 数据源: 使 ...

  9. ArcGIS自定义工具箱-字段值部分替换

    ArcGIS自定义工具箱-字段值部分替换 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:替换某个字段中的字符串 用例:湖南省长沙市=>湖南/长沙:临湘县 ...

随机推荐

  1. 数据库最佳实践:DBA小马如何走上升值加薪之路?

    DBA可能是互联网公司里面熬夜最多,背锅最多的岗位之一,腾讯云数据库团队的同学结合自身的成长经历,用漫画的形式为我们分享了一位DBA是如何从菜鸟成长为大神,走上升职加薪,迎娶白富美之路的. 此文已由作 ...

  2. bash: telnet: command not found

    //安装telnet服务 yum -y install telnet-server //安装telnet客户端 yum -y install telnet.*

  3. 0016_练习题d2

    __author__ = 'qq593' #!/usr/bin/env python #-*- coding:utf-8 -*- #元素分类,有如下值集合[11,22,33,44,55,66,77,8 ...

  4. HDU 4879 ZCC loves march (并查集,set,map)

    题面以及思路:https://blog.csdn.net/glqac/article/details/38402101 代码: #include <bits/stdc++.h> #defi ...

  5. Flow Layout

    --------------siwuxie095                             将根面板 contentPane 的布局切换为 Flow Layout     Flow La ...

  6. Python 安装 django框架

    1.安装 pip install django 2.创建项目 d:/www/django文件夹下右键->打开dos窗口 输入: python C:\ProgramData\Miniconda3\ ...

  7. 主键primary key和唯一索引unique index

    1)主键一定是唯一性索引,唯一性索引并不一定就是主键. 2)主键就是能够唯一标识表中某一行的属性或属性组,一个表只能有一个主键,但可以有多个候选索引. 3)主键常常与外键构成参照完整性约束,防止出现数 ...

  8. ROS Learning-025 (提高篇-003 A Mobile Base-01) 控制移动平台

    ROS 提高篇 A Mobile Base-01 - 控制移动平台 - 基本知识 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubuntu 14.04.4 ...

  9. [转载]HTTP的无状态是什么意思?

    文章地址:https://www.cnblogs.com/bellkosmos/p/5237146.html#commentform 作者:赛艇队长 引子: 最近在好好了解http,发现对介绍http ...

  10. php学习笔记-continue和break

    这两个关键字经常被用在循环中,但作用是完全不同的. 在循环中遇到continue这个单词的时候一定要理解为skip,跳过或者略过,啥意思?就是跳过本次循环,后面的循环继续走起来,老铁. break是说 ...