博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
修改arcgis infowindow 放大和缩小的模板
阅读量:7064 次
发布时间:2019-06-28

本文共 6176 字,大约阅读时间需要 20 分钟。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bitree1/article/details/74029768

在使用arcgis自带的infowindow弹出的详情的时候会有放大和缩小的infowindow显示内容不同的需求,现在此做出处理方法1、设置infowindow模板 (2个table第一个是小的infowindow模板,内容精简就好,第二个是放大的模板内容可以增加)

行 政 区: ${SHENG}${XIAN}${XIANG}
林 业 局: ${LIN_YE_JU}
林 场: ${LIN_CHANG}

2、给图层添加infowindow 
瓦片图层添加infowindows

 

require(["dojo/text!" + layer.infoTemplate], function(content) {var infoTemplate = new InfoTemplate("详细信息", content);var infoTemplates = { 0:{infoTemplate:infoTemplate}, 1:{infoTemplate:infoTemplate} };0:{infoTemplate:infoTemplate},1:{infoTemplate:infoTemplate}};layer = new ArcGISTiledMapServiceLayer(layer.url,layer);layer.setInfoTemplates(infoTemplates);self.map.addLayer(layer);$("#mainMap .esriPopup .titleButton.maximize").unbind('click').click(function() {if ($(this).parents(".esriPopup").find(".contentPane table:first").next().is(":hidden")) {$(this).parents(".esriPopup").find(".contentPane table:first").css("display","none");$(this).parents(".esriPopup").find(".contentPane table").next().css("display","block");}else{if ($(".sider")) {$(".sider").remove();}$(this).parents(".esriPopup").find(".contentPane table:first").css("display","block");$(this).parents(".esriPopup").find(".contentPane table").next().css("display","none");} });});

GraphicLayer添加图层

require(["dojo/text!" + infoTemplate], function(content) {	var infoTemplate = new InfoTemplate("详细信息", content);	graphicsLayer.setInfoTemplate(infoTemplate);});

 

 

3.重写infowindow的放大缩小事件

$("#mainMap .esriPopup .titleButton.maximize").unbind('click').click(function() {            if ($(this).parents(".esriPopup").find(".contentPane table:first").next().is(":hidden")) {                $(this).parents(".esriPopup").find(".contentPane table:first").css("display","none");            	$(this).parents(".esriPopup").find(".contentPane table").next().css("display","block");           }else{
if ($(".sider")) {  $(".sider").remove();}               $(this).parents(".esriPopup").find(".contentPane table:first").css("display","block");               $(this).parents(".esriPopup").find(".contentPane table").next().css("display","none");  }})
如下是给图层设置infowindow的方法,并重写了放大缩小事件
setInfoTemplate: function(graphicsLayer, infoTemplate) {                       var id = graphicsLayer.id;			require(["dojo/text!" + infoTemplate], function(content) {				var infoTemplate = new InfoTemplate("详细信息", content);				graphicsLayer.setInfoTemplate(infoTemplate);			});						 $("#mainMap .esriPopup  .titleButton.maximize").unbind('click').click(function() {				  if ($(this).parents(".esriPopup").find(".contentPane table:first").next().is(":hidden")) {		              $(this).parents(".esriPopup").find(".contentPane table:first").css("display","none");						$(this).parents(".esriPopup").find(".contentPane table").next().css("display","block");				  }else{					  if ($(".sider")) {		                  $(".sider").remove();		              }					  $(this).parents(".esriPopup").find(".contentPane table:first").css("display","block");                      $(this).parents(".esriPopup").find(".contentPane table").next().css("display","none");				  }			  });			 		}

 

 

 

4.infowindow的css

/**infowindow css start**/.esriPopup{font-family: "微软雅黑";font-size: 14px;}.esriPopup.esriPopupVisible .esriPopupWrapper  .sizer{width: 350px !important;max-height: 300px!important}.esriPopup.esriPopupVisible .esriPopupWrapper  .sizer .contentPane{max-height: 300px!important}.esriPopup.esriPopupVisible.esriPopupMaximized .esriPopupWrapper  .sizer{width: 1160px !important;max-height: 800px!important}.esriPopup.esriPopupVisible.esriPopupMaximized .esriPopupWrapper  .sizer .contentPane{max-height: 800px!important}.esriPopup .titlePane{font-weight: 700;font-size: 14px;}/*I信息最大化是,保证最上边*/.esriPopupMaximized {z-index: 1000!important;left: 10px!important;top: 10px!important;}.esriPopup .esriPopupWrapper  .titlePane{background: #ff9c00;color: #fff;}@media print {.no-print {display: none;}}.esriPopup.esriPopupVisible .esriPopupWrapper .info-window-box .item-label {text-align: left;width: 30%;}.esriPopup.esriPopupVisible.esriPopupMaximized .esriPopupWrapper  .info-window-box .item-label {width: 14%;background-color: rgba(255, 156, 0, 0.07);}.esriPopup.esriPopupVisible.esriPopupMaximized .esriPopupWrapper  .info-window-box .item-value{width: 19%;}/**infowindow css end**/.baseLayer{width:99%;margin:12px auto;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}.baseLayer form{width:99%;}.baseLayer table{width:99%;margin-right:18px}.baseLayer table td{border:1px solid #ff9c00;color:#666;padding:4px 8px}.baseLayer table td span{display:inline-block}

5.效果

 

将不定期更新资源,欢迎持续关注


想获得更多的学习知识请关注微信公众号:西北码农或扫下方二维码

你可能感兴趣的文章
记一次对Vulnerable Docker靶机渗透全过程
查看>>
如何使用 Gin 和 Gorm 搭建一个简单的 API 服务 (一)
查看>>
sublime text3简体中文版汉化教程
查看>>
Java网络编程与NIO详解11:Tomcat中的Connector源码分析(NIO)
查看>>
字符串处理文章outline
查看>>
ubuntu12.04 QtCreator ibus 中文输入
查看>>
这次偶遇宁可不要,也要把秘诀送给你们
查看>>
Docker系列教程21-Docker Compose快速入门
查看>>
SmartDeblur-图片模糊处理器
查看>>
2018 年最常见的 Python 面试题 & 答案
查看>>
金陵怀古——游梅花山、明孝陵记
查看>>
算法与数据结构(六)并查集
查看>>
Android 开发小知识点收集(随时更新)
查看>>
如何为你的微信小程序瘦身?
查看>>
微信小程序正式发布,符合你的预期么?
查看>>
最最最常见的Java面试题总结-第一周
查看>>
是否可以从一个静态(static)方法内部发出对非静态(non-static)方法的调用?...
查看>>
MacOS下SVN迁移Git踩坑记
查看>>
14 -Flask构建弹幕微电影网站-后台逻辑(六)
查看>>
思考 | 云计算 + 区块链 = ?
查看>>