ArcGIS For JavaScript API Overview Map(鹰眼/概览图) ————(二十五)

转载自:http://blog.csdn.net/xiaokui_wingfly/article/details/8508026


描述:

此示例显示了如何添加一个的地形底图层到您的应用程序和使用OverviewMap的dijit显示的主要地图右上角的总览图。总览图的dijit最初发表在ESRI的代码库作为样本,并添加到ArcGISJavaScript API的2.0版本。要添加到您的应用程序的概述地图,下面的代码添加到地图的onLoad事件:

var overviewMapDijit= new esri.dijit.OverviewMap({map:map});
overviewMapDijit.startup();

上面的代码添加总览图中的默认位置(右上角)。您可以修改此使用attachTo参数。使用此参数,您可以指定总览图将附加到下列地点之一:bottom-right,bottom-left, top-right 或 top-left 

在线演示:http://help.arcgis.com/en/webapi/javascript/arcgis/samples/widget_overviewmap/index.html

引用参考:http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/widget_overviewmap

 

 代码如下:

 

[html]  view plain copy
  1. <!DOCTYPE html>  
  2. <html>  
  3.   <head>  
  4.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">  
  5.     <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9">  
  6.     <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices-->  
  7.     <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">  
  8.     <title>Overview Map</title>  
  9.     <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/dijit/themes/claro/claro.css">  
  10.     <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css">  
  11.     <style>  
  12.       html, body { height: 100%; width: 100%; margin: 0; padding: 0; }  
  13.     </style>  
  14.   
  15.     <script>  
  16.         var dojoConfig = {   
  17.             parseOnLoad: true   
  18.         };  
  19.     </script>  
  20.     <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/"></script>  
  21.     <script>  
  22.         // 导入必要包  
  23.       dojo.require("dijit.layout.BorderContainer");  
  24.       dojo.require("dijit.layout.ContentPane");  
  25.       dojo.require("esri.map");  
  26.       dojo.require("esri.dijit.OverviewMap");  
  27.       var map;  
  28.   
  29.       function init() {  
  30.         map = new esri.Map("map", {  
  31.           basemap: "topo", // 指定的地图底图.有效选项:"streets","satellite","hybrid","topo","gray","oceans","national-geographic","osm".  
  32.           center: [-122.445, 37.752],   // 居中的经纬度  
  33.           zoom: 14  // 缩放深度级别  
  34.         });  
  35.   
  36.         dojo.connect(map, "onLoad", function(theMap) {  
  37.           // 添加概览地图  
  38.           var overviewMapDijit = new esri.dijit.OverviewMap({  
  39.             map: map,   // 必要的  
  40.             visible: true,  // 初始化可见,默认为false  
  41.             attachTo: "bottom-right",   // 默认右上角  
  42.             width: 150, // 默认值是地图高度的 1/4th  
  43.             height: 150, // 默认值是地图高度的 1/4th   
  44.             opacity: .40,    // 透明度 默认0.5  
  45.             maximizeButton: true,   // 最大化,最小化按钮,默认false  
  46.             expandFactor: 3,    //概览地图和总览图上显示的程度矩形的大小之间的比例。默认值是2,这意味着概览地图将至少是两倍的大小的程度矩形。  
  47.             color: "red"    // 默认颜色为#000000  
  48.           });  
  49.           overviewMapDijit.startup();   // 开启  
  50.         });  
  51.       }  
  52.   
  53.       dojo.ready(init);  
  54.     </script>  
  55.   </head>  
  56.     
  57.   <body class="claro">  
  58.     <div data-dojo-type="dijit.layout.BorderContainer"   
  59.          data-dojo-props="design:'headline', gutters:false"   
  60.          style="width: 100%; height: 100%; margin:0;">  
  61.   
  62.       <div id="map"   
  63.            data-dojo-type="dijit.layout.ContentPane"   
  64.            data-dojo-props="region:'center'"   
  65.            style="padding:0">  
  66.       </div>  
  67.     </div>  
  68.   </body>  
  69. </html>  


效果图如下:

 

 

如果需要将鹰眼地图放在地图外面可以使用布局,然后使用以下方法即可

var overviewMapDijit = new esri.dijit.OverviewMap({map:map}, dojo.byId('overviewMapDiv');
overviewMapDijit.startup();

参考联接:http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/widget_overviewmapexternal

在线演示:http://help.arcgis.com/en/webapi/javascript/arcgis/samples/widget_overviewmapexternal/index.html

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值