描述

如果在海洋中丢下一个瓶子,本例使用颗粒追踪模型显示指定的天数后瓶子在的地方。首先,输入一个追踪瓶子的天数。然后单击按钮并在海洋里的任意地方画一个点来开始模型。几秒以后将看到一条线出现描述瓶子将去的地方。

关于这个模型的更多信息,见本例中引用的ArcGIS Server地理处理任务的服务目录页: http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer/MessageInABottle。这个页面列出了模型的参数并包含一个如何创建模型的帮助URL。

本例使用绘画工具栏帮助画点。工具栏不是一个可以加到页面的用户界面组件。而是一个帮助类,能够画某一几何体类型。更多信息见示例使用一个绘画工具栏

 <!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>ArcGIS Geoprocessing and ArcGIS Server JavaScript API</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");
dojo.require("esri.tasks.gp");
dojo.require("esri.toolbars.draw"); var map, gp, toolbar; function init() {
map = new esri.Map("mapDiv");
var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer");
map.addLayer(streetMap);
gp = new esri.tasks.Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_Currents_World/GPServer/MessageInABottle");
//esri.toolbars.Draw(map, options) 创建一个新的绘图对象。地图是必要的参数。
toolbar = new esri.toolbars.Draw(map); dojo.connect(toolbar,"onDrawEnd",executeParticleTrack); } function executeParticleTrack(geometry) { map.graphics.clear();
//使用一张图片定义样式。这是最常用的渲染方式之一。
//我们通常的应用都会使用这一样式,使地图图元的意义更加明朗,地图也更加的美观。
var simplePictureMarkerSymbol = new esri.symbol.PictureMarkerSymbol('http://www.esri.com/graphics/aexicon.jpg', 26, 26);
var graphic = new esri.Graphic(geometry,simplePictureMarkerSymbol);
map.graphics.add(graphic);
toolbar.deactivate();//None 关闭工具栏并激活地图导航. var features = [];
features.push(graphic);
var featureSet = new esri.tasks.FeatureSet();
featureSet.features = features; var params = { "Input_Point":featureSet, "Days": dojo.byId("days").value };
gp.execute(params, displayTrack); } function displayTrack(results, messages) {
alert(222);
var simpleLineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,0]), 1);
var features = results[0].value.features;
for(var i=0,j=features.length;i<j;i++) {
var feature = features[i];
feature.setSymbol(simpleLineSymbol);
map.graphics.add(feature);
} } dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
<table>
<tbody>
<tr>
<td>Select tool to draw and execute the particle tracker model.
<br>Start season is Spring. Number of days to track = <input type="text" id="days" value="180" size="3"/>.
&nbsp;&nbsp;<button onclick="toolbar.activate(esri.toolbars.Draw.POINT);">Draw and execute particle track.</button>
</td>
</tr>
<tr>
<td id="mapDiv" style="width:800px; height:600px; border:1px solid #000;"></td>
</tr>
</tbody>
</table>
</body>
</html>
05-20 14:13