地理处理服务(GP)的实现

      这里只是自己发布的buffer point地理处理服务http://localhost:8399/rest/services/buffer/GPServer/BufferPoints,具体的实现代码参照官网的demo,只是换了几行代码,实现的小例子,关键是弄清楚过程。

<!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"/> 

    <!--The viewport meta tag is used to improve the presentation and behavior of the samples  
      on iOS devices--> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> 
    <title>ArcGIS Geoprocessing and ArcGIS Server JavaScript API</title> 
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/claro/claro.css"> 
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css" /> 
 
    <script type="text/javascript"> 
      djConfig = { 
        parseOnLoad:true 
      } 
    </script> 
    <style> 
      html, body { height: 100%; width: 100%; margin: 0; padding: 0; } 
    </style>    
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"></script> 
    <script type="text/javascript"> 
      dojo.require("esri.map"); 
      dojo.require("esri.tasks.gp"); 
      dojo.require("esri.toolbars.draw"); 
      dojo.require("dijit.layout.BorderContainer"); 
      dojo.require("dijit.layout.ContentPane"); 
       
      var map, gp, toolbar; 
 
      function init() { 
        var initExtent = new esri.geometry.Extent({"xmin":-12689769,"ymin":-1937220,"xmax":2964533,"ymax":9725235,"spatialReference":{"wkid":102100}}); 
        map = new esri.Map("map",{extent:initExtent}); 
         
        var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"); 
         
        map.addLayer(streetMap); 
         
        //setup the geoprocessor teask 
        gp = new esri.tasks.Geoprocessor("http://localhost:8399/rest/services/buffer/GPServer/Buffer Points"); 
        gp.setOutSpatialReference({wkid:102100}); 
         
        toolbar = new esri.toolbars.Draw(map); 
        dojo.connect(toolbar, "onDrawEnd", executeParticleTrack); 
         
         
        //resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in  
        //the following help topic for more details http://help.esri.com/EN/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_guidelines.htm 
        var resizeTimer; 
        dojo.connect(map, 'onLoad', function(theMap) { 
          //resize the map when the browser resizes 
          dojo.connect(dijit.byId('map'), 'resize', map,map.resize); 
        }); 
      } 
 
      function executeParticleTrack(geometry) { 
       
        map.graphics.clear(); 
       
        
        var graphic = new esri.Graphic(geometry); 
        map.graphics.add(graphic); 
         
        toolbar.deactivate(); 
 
        var features= []; 
        features.push(graphic); 
        var featureSet = new esri.tasks.FeatureSet(); 
        featureSet.features = features; 
		
	    //客户端输入参数
        var vsDistance = new esri.tasks.LinearUnit(); 
        vsDistance.distance = dojo.byId("distance").value; 
        vsDistance.units = "esriMiles"; 
   
        var params = { "Input_Points":featureSet, "Distance": vsDistance }; 
        gp.execute(params, displayTrack); 
      } 
 
      function displayTrack(results, messages) { 
	  //客户端渲染
	  var polySymbol = new esri.symbol.SimpleFillSymbol(); 
        polySymbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,0,0.5]), 1)); 
        polySymbol.setColor(new dojo.Color([255,127,0,0.7])); 
        var features = results[0].value.features; 
        for (var f=0, fl=features.length; f<fl; f++) { 
          var feature = features[f]; 
          feature.setSymbol(polySymbol); 
          map.graphics.add(feature); 
        } 
      } 
      dojo.addOnLoad(init); 
    </script> 
  </head> 
  <body class="claro"> 
  <div dojotype="dijit.layout.BorderContainer" design="sidebar" style="width:100%;height:100%;margin:0px;" gutters="true"> 
    <div dojotype="dijit.layout.ContentPane" region="left" style="width:300px;"> 
      <ol> 
        <li>Enter the number of days to track:<input type="text" id="distance"
		value="5" size="3"/></li> 
        <li>Click the  <button οnclick="toolbar.activate(esri.toolbars.Draw.POINT);"> Execute</button> button. </li> 
        <li>Click the map to specify the start point.</li> 
      </ol> 
      * Note that the start season is spring. 
    </div> 
    <div dojotype="dijit.layout.ContentPane" id="map" region="center"></div> 
  </div> 
  </body> 
</html> 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值