(转)Arcgis for JS之地图自适应调整
http://blog.csdn.net/gisshixisheng/article/details/42675897
概述:本节讲述的内容为当浏览器大小发生变化或者地图展示区域的大小发生变化时,地图的自适应调整。地图的自适应常见于以下几种情况:1、系统中有收缩或者全屏的按钮;2、按F12,进入调试状态。
其实,地图自适应调整是一个很简单的事情,但是大多数我们的系统中会用到,实现地图的自适应主要是map div的大小的自适应调整,代码如下:
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
- <title>Simple Map</title>
- <link rel="stylesheet" href="http://localhost/arcgis_js_api/library/3.9/3.9/js/esri/css/esri.css">
- <style>
- html, body, #left, #map {
- height: 100%;
- margin: 0;
- padding: 0;
- }
- body {
- background-color: #fff;
- overflow: hidden;
- font-family: "Trebuchet MS";
- }
- #left{
- float: left;
- width:200px;
- background: #014CC9;
- }
- .collapse_btn{
- position: absolute;
- top: 50%;
- left: 0px;
- z-index: 99;
- }
- .collapse_btn_a{
- padding: 10px 0px;
- background: #33CCFF;
- border-radius: 3px;
- }
- .collapse_btn_a:hover{
- cursor: pointer;
- background: #11aaFF;
- }
- #map{
- position: relative;
- float: left;
- width:800px;
- background: #7EABCD;
- }
- </style>
- <script src="http://localhost/arcgis_js_api/library/3.9/3.9/init.js"></script>
- <script src="jquery-1.8.3.js"></script>
- <script>
- var map;
- require([
- "esri/map",
- "esri/layers/ArcGISTiledMapServiceLayer",
- "dojo/on",
- "dojo/dom",
- "dojo/domReady!"],
- function(Map,
- Tiled,
- on,
- dom
- ) {
- $("#map").css("width",($(window).width()-200)+"px");
- map = new Map("map",{logo:false,autoResize:true});
- var tiled = new Tiled("http://localhost:6080/arcgis/rest/services/image/MapServer");
- map.addLayer(tiled);
- var mapCenter = new esri.geometry.Point(103.847, 36.0473, map.spatialReference);
- map.centerAndZoom(mapCenter,4);
- on(dom.byId("collapse_btn"), "click", function(){
- var collapseState = $("#collapse_btn").html();
- console.log(collapseState);
- if(collapseState==="《"){//折叠DIV
- console.log(true);
- $("#collapse_btn").html("》");
- $("#left").hide();
- $("#map").css("width",($(window).width())+"px");
- map.resize(true);
- map.reposition();
- }
- else{//展开DIV
- console.log(false);
- $("#collapse_btn").html("《");
- $("#left").show();
- $("#map").css("width",($(window).width()-200)+"px");
- map.resize(true);
- map.reposition();
- }
- });
- });
- window.onresize=function(){
- var collapseState = $("#collapse_btn").html();
- if(collapseState==="《"){//展开状态
- $("#map").css("width",($(window).width()-200)+"px");
- map.resize(true);
- map.reposition();
- }
- else{//折叠状态
- $("#map").css("width",($(window).width())+"px");
- map.resize(true);
- map.reposition();
- }
- }
- </script>
- </head>
- <body>
- <div id="left"></div>
- <div id="map">
- <div class="collapse_btn">
- <a id="collapse_btn" class="collapse_btn_a" title="点击折叠">《</a>
- </div>
- </div>
- </body>
- </html>
实现后的效果如下:



(转)Arcgis for JS之地图自适应调整的更多相关文章
- (转) Arcgis for js加载百度地图
http://blog.csdn.net/gisshixisheng/article/details/44853709 概述: 在前面的文章里提到了Arcgis for js加载天地图,在本节,继续讲 ...
- Arcgis for js加载百度地图
看转:https://blog.csdn.net/qq_41046162/article/details/80248281 通过学习了一段时间的arcgis for js,让我来讲一下如何在arcgi ...
- arcgis js之地图分屏同步
arcgis js之地图分屏同步 原理: 新建两个map两个view或者一个map两个view.对地图进行移动事件绑定,在地图移动时同步地图方位 代码: views.forEach((view) =& ...
- ArcGis API JS 4.X本地化部署与地图的基础使用
准备工作 首先下载ArcGIS API for JavaScript4.x,这里下载的是4.19. 官方下载地址:https://developers.arcgis.com/downloads/ ar ...
- Arcgis for Js之鼠标经过显示对象名的实现
在浏览地图时,移动鼠标经过某个对象或者POI的时候,能够提示该对象的名称对用户来说是很实用的,本文讲述在Arcgis for Js中,用两种不同的方式来实现该效果. 为了有个直观的概念,先给大家看看实 ...
- (转)Arcgis for Js之鼠标经过显示对象名的实现
http://blog.csdn.net/gisshixisheng/article/details/41889345 在浏览地图时,移动鼠标经过某个对象或者POI的时候,能够提示该对象的名称对用户来 ...
- Arcgis for JS之Cluster聚类分析的实现(基于区域范围的)
原文:Arcgis for JS之Cluster聚类分析的实现(基于区域范围的) 咱们书接上文,在上文,实现了基于距离的空间聚类的算法实现,在本文,将继续介绍空间聚类之基于区域范围的实现方式,好了,闲 ...
- Arcgis for JS之Cluster聚类分析的实现
原文:Arcgis for JS之Cluster聚类分析的实现 在做项目的时候,碰见了这样一个问题:给地图上标注点对象,数据是从数据库来 的,包含XY坐标信息的,通过graphic和graphicla ...
- Arcgis for js载入天地图
综述:本节讲述的是用Arcgis for js载入天地图的切片资源. 天地图的切片地图能够通过esri.layers.TiledMapServiceLayer来载入.在此将之进行了一定的封装,例如以下 ...
随机推荐
- 【codeforces 767A】Snacktower
[题目链接]:http://codeforces.com/contest/767/problem/A [题意] 每天掉一个盘子下来;盘子有大小从1..n依次增大n个盘子; 然后让你叠盘子; 最底层为n ...
- java后台处理解析json字符串的两种方式
简单说一下背景 上次后端通过模拟http请求百度地图接口,得到的是一个json字符串,而我只需要其中的某个key对应的value. 当时我是通过截取字符串取的,后来觉得不太合理,今天整理出了两种处理解 ...
- EXt js 学习笔记总结
1. get . fly. getCmp .getBody .getDoc .getDom.. get-----ExtJs获取节点.dom.提供缓存机制 Ext.Element类是Ext对DO ...
- H - Seek the Name, Seek the Fame
The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the l ...
- 洛谷——P1034 矩形覆盖
https://www.luogu.org/problem/show?pid=1034 题目描述 在平面上有 n 个点(n <= 50),每个点用一对整数坐标表示.例如:当 n=4 时,4个点的 ...
- N天学习一个linux命令之df
用途 查看系统硬盘空间使用情况 用法 df [OPTION]... [FILE]... 常用参数 -a, --all 显示所有文件系统,包含类似文件系统(dummy file system) -B, ...
- linux 下ip命令对比ifconfig命令
原文:https://linux.cn/article-3144-1.html ------------------------------------------------------------ ...
- 【Java集合源代码剖析】Hashtable源代码剖析
转载请注明出处:http://blog.csdn.net/ns_code/article/details/36191279 Hashtable简单介绍 Hashtable相同是基于哈希表实现的,相同每 ...
- axis2的wsdl无法使用eclipse axis1插件来生成client--解决方法
使用jetty+axis2实现webservice服务端,且无需使用axis2命令生成服务端代码.仅仅要services.xml配置实现类. project为gradleproject配置文件在src ...
- JFreeChart之堆叠柱形图(StackedBar)
JFreeChart之堆叠柱形图(StackedBar) JAVA JFreeChart 最近的项目使用有个功能需要使用到堆叠柱形图,看了项目以前的代码实现没有想要的结果.所以自己就先到官网下载了 D ...