(转)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来载入.在此将之进行了一定的封装,例如以下 ...
随机推荐
- 【[Offer收割]编程练习赛12 C】矩形分割
[题目链接]:http://hihocoder.com/problemset/problem/1495 [题意] [题解] 把每个方块都再分成3*3的小块; 这样; 对于一个方块来说 如果是'\' 则 ...
- 【转】How Many Boyfriends
如果一个女人遇到不同星座男的概率相同 那么这个女人期望遇到多少个男人就能集齐12个不同星座的男人 我们简化一下问题. 如果只有一个星座,那么期望值为1 如果只有两个星座,那遇到第一个男人后 期望再遇到 ...
- TestNG的安装和使用
一.TestNG安装 打开这个网址:https://marketplace.eclipse.org/content/testng-eclipse#group-external-install-butt ...
- hdu 3549 最大流
#include<stdio.h> #include<string.h> #include<queue> #include<iostream> usin ...
- 网页title上面添加图片
1.效果:
- 洛谷——P2722 总分 Score Inflation
https://www.luogu.org/problem/show?pid=2722 题目背景 学生在我们USACO的竞赛中的得分越多我们越高兴. 我们试着设计我们的竞赛以便人们能尽可能的多得分,这 ...
- 开启IIS的动态gzip功能
首先安装IIS的动态压缩模块 然后打开system32/intesrv下的applicationhost文件,找到其中的webServer节点,将其中的压缩配置部分替换如下: <?xml ver ...
- 网络基础篇(一)--TCP/IP协议族
TCP/IP协议族是一个分层,多协议通信体系. 1 TCP/IP协议族体系结构 TCP/IP协议族自底而上分为四层: 数据链路层, 网络层, 传输层和应用层. 1.1 数据链路层 实现网卡接口的网络驱 ...
- Linq查询datatable的记录集合
通过linq查询datatable数据集合满足条件的数据集 1.首先定义查询字段的变量,比方深度 string strDepth=查询深度的值: var dataRows = from datarow ...
- loosejar原理简要分析
loosejar这个小工具能够动态分析出应用中有每一个jar包的实际使用情况,详情请參阅<通过loosejar清理应用中冗余的jar包>基本原理是利用instrumentation的特性用 ...