ArcGIS api for javascript——地图配置-定制缩放动画

时间:2024-06-03 09:33:08

描述

本例展示了当用户放大或缩小地图时如何定义地图的动画。zoomDuration和zoomRate是Dojo动画属性,他们确定了动画的duration和帧刷新的rate 。这些属性单位是毫秒,zoomDuration默认值是250,zoomRate默认值是25。

在本例中,可以通过调整这些属性为数据和应用获得更好的样子。例如,如果地图需要很长的时间加载,可以增加zoomDuration以便用户在等待加载缩放地图时看到空的或扭曲的屏幕时间较短。反之,如果地图加载很快,可以降低zoomDuration值来给地图更快的感觉。

本例展示了单击并拖拽鼠标期间按下Shift键时如何改变显示的缩放框的默认符号。能够定义任意填充符号作esriConfig里面的zoomSymbol。如同这个代码行所示:

esriConfig.defaults.map.zoomSymbol = {"color":[255,255,255,127],"outline":{"color":[255,0,0,255],"width":1.5,"style":"esriSLSDash"},"style":"esriSFSSolid"};

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>定制缩放动画</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.5/js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.5"></script>
<script type="text/javascript"> dojo.require("esri.map");
function init() { //定制缩放动画
/* esriConfig.defaults.map.zoomDuration = 1000; //time in milliseconds; default is 250
esriConfig.defaults.map.zoomRate = 50; //refresh rate of zoom animation; default is 25 */ //定制缩放框
var zoomSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT,
new dojo.Color([0,0,255]), 2), new dojo.Color([255,255,0,0.5])); esriConfig.defaults.map.zoomSymbol = zoomSymbol.toJson();
var map = new esri.Map("map",{nav:false});
var layer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");
map.addLayer(layer);
}
dojo.addOnLoad(init); </script>
</head>
<body class="tundra">
<div id="map" style="width:1024px; height:512px; border:1px solid #000;"></div>
</body>
</html>