通过div实现arcgis自定义infowindow
通过给地图绑定缩放,单击和平移命令,实现在地图附加div标签,实现infowindow效果;
- /*
- *作者 扰扰
- *自定义esri弹窗
- *paramter Map地图对象
- *paramter x
- *paramter y
- *paramter title标题
- *paramter html展示内容html字符串
- *paramter height弹窗高度默认为300
- *paramter width弹窗宽度默认为200
- */
- RaoRao.esriDivPanel = function (Map, x, y, title, html, height, width) {
- //加载时地图坐标
- var X = x, Y = y, map = Map;
- //弹窗宽度
- var Heigth = 300;
- if (height) { Height = height }
- //弹窗高度
- var Width = 400;
- if (width) { Width = width }
- //弹窗位置
- var top = 0;
- //弹窗位置
- var left = 0;
- //弹窗对象
- var Div = null;
- //移动量
- var movX = 0, movY = 0;
- //变化量
- var tempX = 0, tempY = 0;
- //地图拖拽事件
- this._panEvt = null;
- this._panEndEvt = null;
- //地图所缩放事件
- this._zoomStartEvt = null;
- this._zoomEndEvt = null;
- //弹窗DIV
- this.div = document.createElement("div");
- Div = this.div;
- this.div.className = "esriDivPanel";
- var divcss = 'width:' + Width + 'px;height:' + Heigth + 'px;';
- this.div.style.cssText = divcss;
- this.title = document.createElement("div");
- this.title.className = "esriDivPanel_title";
- var close = document.createElement("div");
- close.className = "esriDivPanel_titleClose";
- close.innerHTML = "<span></span>";
- var titletext = document.createElement("div");
- titletext.className = "esriDivPanel_titleTxt";
- titletext.innerHTML = title;
- this.content = document.createElement("div");
- this.content.className = "esriDivPanel_content";
- this.content.innerHTML = html;
- this.content.style.cssText = "height:" + (Heigth - 32) + "px;";
- this.triangle = document.createElement("div");
- this.triangle.className = "esriDivPanel_triangle";
- this.title.appendChild(close);
- this.title.appendChild(titletext);
- this.div.appendChild(this.title);
- this.div.appendChild(this.content);
- this.div.appendChild(this.triangle);
- var point = new esri.geometry.Point(x, y, map.spatialReference);
- var p = map.toScreen(point);
- top = p.y - Heigth-36;
- left = p.x - Width / 2;
- this.div.style.top = top + "px";
- this.div.style.left = left + "px";
- document.getElementById(map.id).appendChild(this.div);
- //定义地图缩放事件
- this._zoomStartEvt = map.on("zoom-start", function (evt) {
- //Div.style.display = "none";
- var point = new esri.geometry.Point(X, Y, map.spatialReference);
- var p = map.toScreen(point);
- top = p.y - Heigth - 36;
- left = p.x - Width / 2;
- Div.style.top = top + "px";
- Div.style.left = left + "px";
- });
- this._zoomEndEvt = map.on("zoom-end", function (evt) {
- //Div.style.display = "block";
- var point = new esri.geometry.Point(X, Y, map.spatialReference);
- var p = map.toScreen(point);
- top = p.y - Heigth - 36;
- left = p.x - Width / 2;;
- Div.style.top = top + "px";
- Div.style.left = left + "px";
- });
- //定义地图拖拽事件
- this._panEvt = map.on("pan", function (evt) {
- var point = evt.delta;
- movX = point.x - tempX;
- movY = point.y - tempY;
- tempX = point.x; tempY = point.y;
- top = top + movY;
- left = left + movX;
- Div.style.top = top + "px";
- Div.style.left = left + "px";
- });
- this._panEndEvt = map.on("pan-end", function (evt) {
- tempX = 0;
- tempY = 0;
- });
- //定义关闭事件
- close.onclick = function () {
- if (this._panEndEvt) {
- this._panEndEvt.remove();
- }
- if (this._panEvt) {
- this._panEvt.remove();
- }
- if (this._zoomEndEvt) {
- this._zoomEndEvt.remove();
- }
- if (this._zoomStartEvt) {
- this._zoomStartEvt.remove();
- }
- this._panEndEvt = null;
- this._panEvt = null;
- this._zoomEndEvt = null;
- this._zoomStartEvt = null;
- document.getElementById(map.id).removeChild(Div);
- }
- }
- .esriDivPanel {
- position: absolute;
- z-index:;
- }
- .esriDivPanel_title {
- border: 2px solid #333;
- height: 32px;
- width: 100%;
- background-color: #333;
- border-radius: 5px 5px 0px 0px;
- }
- .esriDivPanel_titleClose {
- float: right;
- width: 24px;
- height: 24px;
- margin: 5px;
- }
- .esriDivPanel_titleClose span {
- display: inline-block;
- width: 100%;
- height: 100%;
- text-align: center;
- overflow: hidden;
- position: relative;
- }
- .esriDivPanel_titleClose span:hover {
- background-color: slategrey;
- }
- .esriDivPanel_titleClose span::before, .esriDivPanel_titleClose span::after {
- position: absolute;
- content: '';
- top: 50%;
- left:;
- margin-top: -1px;
- background-color: #fff;
- width: 100%;
- height: 3px;
- }
- .esriDivPanel_titleClose span::before {
- -webkit-transform: rotate(45deg);
- -moz-transform: rotate(45deg);
- }
- .esriDivPanel_titleClose span::after {
- -webkit-transform: rotate(-45deg);
- -moz-transform: rotate(-45deg);
- }
- .esriDivPanel_titleTxt {
- overflow: hidden;
- width: 75%;
- height: 32px;
- line-height: 32px;
- margin-left: 5px;
- color: white;
- }
- .esriDivPanel_content {
- width: 100%;
- border: 2px solid #8c9794;
- background-color: #f8f8f8;
- overflow: hidden;
- }
- .esriDivPanel_triangle {
- width: 0px;
- height: 0px;
- margin-left: 50%;
- /* background-color: #8c9794; */
- border-top: 20px solid #333;
- /* border-bottom: 20px solid rgba(140, 151, 148, 0.57); */
- border-right: 40px solid rgba(140, 151, 148, 0);
- border-left: 0px solid rgba(140, 151, 148, 0.26);
- }
再系统中引用代码就可以直接调用
通过div实现arcgis自定义infowindow的更多相关文章
- lzugis——Arcgis Server for JavaScript API之自定义InfoWindow(续)
同样的标题后面加了一个括弧,不是为了增减博文数量,而确实是上个功能的完善,标注为续,意思是继续上次的内容,来说说如何自定义InfoWindow. 在上一讲中,实现了InfoWindow的显示,但是并没 ...
- ArcGIS自定义脚本-通过txt/excel/dbf/table生成多边形要素类
ArcGIS自定义脚本-通过txt/excel/dbf/table生成多边形要素类 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:读取文本文件,常见多边形要素 ...
- ArcGIS自定义工具箱-列举损坏的数据源
ArcGIS自定义工具箱-列举损坏的数据源 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:查找地图文档中损坏的数据源链接 使用方法:参数可选,默认为当前(ar ...
- ArcGIS自定义工具箱-修复损坏的工作空间
ArcGIS自定义工具箱-修复损坏的工作空间 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:替换数据源的工作空间 用途:针对损坏的数据源,批量进行修复 案例数 ...
- ArcGIS自定义工具箱-显示地图文档结构
ArcGIS自定义工具箱-显示地图文档结构 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:显示地图文档mxd的数据组织结构,数据框,图层,表 使用方法: 地图 ...
- ArcGIS自定义工具箱-清空工作空间
ArcGIS自定义工具箱-清空工作空间 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:删除工作空间里的要素类,栅格和独立表 使用方法: 例如"C:\ ...
- ArcGIS自定义工具箱-字段合并
ArcGIS自定义工具箱-字段合并 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:用指定字符合并两个字段 用例:湖南/长沙=>湖南省长沙市 数据源: 使 ...
- ArcGIS自定义工具箱-字段分割
ArcGIS自定义工具箱-字段分割 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:用指定分割符分割字段, 用例:湖南省长沙市=>湖南/长沙 数据源: 使 ...
- ArcGIS自定义工具箱-字段值部分替换
ArcGIS自定义工具箱-字段值部分替换 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:替换某个字段中的字符串 用例:湖南省长沙市=>湖南/长沙:临湘县 ...
随机推荐
- 数据库最佳实践:DBA小马如何走上升值加薪之路?
DBA可能是互联网公司里面熬夜最多,背锅最多的岗位之一,腾讯云数据库团队的同学结合自身的成长经历,用漫画的形式为我们分享了一位DBA是如何从菜鸟成长为大神,走上升职加薪,迎娶白富美之路的. 此文已由作 ...
- bash: telnet: command not found
//安装telnet服务 yum -y install telnet-server //安装telnet客户端 yum -y install telnet.*
- 0016_练习题d2
__author__ = 'qq593' #!/usr/bin/env python #-*- coding:utf-8 -*- #元素分类,有如下值集合[11,22,33,44,55,66,77,8 ...
- HDU 4879 ZCC loves march (并查集,set,map)
题面以及思路:https://blog.csdn.net/glqac/article/details/38402101 代码: #include <bits/stdc++.h> #defi ...
- Flow Layout
--------------siwuxie095 将根面板 contentPane 的布局切换为 Flow Layout Flow La ...
- Python 安装 django框架
1.安装 pip install django 2.创建项目 d:/www/django文件夹下右键->打开dos窗口 输入: python C:\ProgramData\Miniconda3\ ...
- 主键primary key和唯一索引unique index
1)主键一定是唯一性索引,唯一性索引并不一定就是主键. 2)主键就是能够唯一标识表中某一行的属性或属性组,一个表只能有一个主键,但可以有多个候选索引. 3)主键常常与外键构成参照完整性约束,防止出现数 ...
- ROS Learning-025 (提高篇-003 A Mobile Base-01) 控制移动平台
ROS 提高篇 A Mobile Base-01 - 控制移动平台 - 基本知识 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubuntu 14.04.4 ...
- [转载]HTTP的无状态是什么意思?
文章地址:https://www.cnblogs.com/bellkosmos/p/5237146.html#commentform 作者:赛艇队长 引子: 最近在好好了解http,发现对介绍http ...
- php学习笔记-continue和break
这两个关键字经常被用在循环中,但作用是完全不同的. 在循环中遇到continue这个单词的时候一定要理解为skip,跳过或者略过,啥意思?就是跳过本次循环,后面的循环继续走起来,老铁. break是说 ...