---
title: "REST API下的ArcServer 9.3.0与9.3.1使用Javascript实现路径分析的不同方式"
author: "NickWar"
date: "2009-08-11T09:01:00Z"
tags: []
slug: "rest-api-arcserver-9-3-0-9-3-1-javascript"
draft: false
lastmod: "2012-04-20T20:55:52Z"
id: 1492386
url: "https://nickwar.iteye.com/blog/1492386"
---

上次说了，9.3.0中没有直接的对routeTask进行支持，但是跟ESRI的工程师联系了下，对方有解决方案，就是使用GeoProcessing Service来做，用了发现这个GPserver还是很强大的，可以做的事情还有缓冲区之类的，挺好。

使用9.3.0做路径分析的时候，数据要使用建模工具做一下，具体的模型做法及服务设置可参考这里

[http://webhelp.esri.com/arcgisserver/**9.3**/java/index.htm#geoprocessing/guide\_-1963186772.htm](http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#geoprocessing/guide_-1963186772.htm)

**发布完数据后，在javascript中使用GPserver，可参考Geoprocessor Task的官方示例，关键代码如下：**

**\_gpShortService = new esri.tasks.Geoprocessor(\_GPShortRouteURL);**

**\_routeParams = new esri.tasks.FeatureSet();**

**添加起点终点，在地图的onClick事件中处理**

**var stop = map.graphics.add(new esri.Graphic(evt.mapPoint, stopSymbol));**

**\_routeParams.features.push(stop);**

**设置参数具体内容**

**var params = { "Feature\_set":\_routeParams };**

**在这里，“Feature\_set”是根据不同的处理模型中定义的输入参数名称，可能不同**

**执行路径分析：**

**\_gpShortService.execute(params,showRoute,errorHandler);**

**参数第一个不用说了，第二个是结果集处理，第三个是错误处理**

**如下：**

**showRoute(routeResults, messages)**

**路径结果按这样取出：routeResults\[0].value.features\[0];**

**然后对其setSymbol就可以显示在地图上了。**