ilyass

Change a geometry service to a geoprocessing service

Discussion created by ilyass on Jan 14, 2014
Latest reply on Jan 25, 2014 by ilyass
Hi everyone,

I need your help in one problem that i am facing the last 3 days.
I create one web app using javascript that allow me to add point in the map and create buffer around each point (I used Geometry Service), now i should merge any buffer who intersect with the other one, so i create one model in model builder using Dissolve All and i publish it as a geoprocessing service.
That give me a url like: http://IP:6080/arcgis/rest/services/Service_Name/GPServer/Model_Name.

I tried to repalce the URL that i used for the geometry service by this URL but its not working.
Below is the Head code for the geometry service if you can help me to found the changes that i should do to have the result.

require(["dojo/dom",
          "dojo/dom-attr",
          "dojo/_base/array",
          "dojo/_base/Color",
          "dojo/parser",

          "esri/config",
          "esri/map",
          "esri/graphic",
   
          "esri/tasks/GeometryService",
          "esri/tasks/BufferParameters",
   
          "esri/toolbars/draw",
   
          "esri/symbols/SimpleMarkerSymbol",
          "esri/symbols/SimpleLineSymbol",
          "esri/symbols/SimpleFillSymbol",
         
          "dijit/layout/BorderContainer",
          "dijit/layout/ContentPane"],
   
    function(dom, domAttr, array, Color, parser, esriConfig, Map,
Graphic, GeometryService, BufferParameters, Draw, SimpleMarkerSymbol,
SimpleLineSymbol, SimpleFillSymbol)

{
      var map, geo, tb;
     
   parser.parse();
      map = new Map("map", {
        basemap: "streets",
        center: [-122.4, 37.785],
        zoom: 13,
      });
  
esriConfig.defaults.io.proxyUrl = "/proxy";
    esriConfig.defaults.io.alwaysUseProxy = false;  

geo = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
  
    map.on("load", initToolbar);

/*
**  Initialize the drawing toolbar
*/
function initToolbar(evtObj) {
      app.tb = new Draw(evtObj.map);
      app.tb.on("draw-end", drawPoint);
    }

// Array where points are saved
var list = new Array();

/*
    ** Draw point
*/
function drawPoint(evtObj) {
      // Get the click geometry
   var geometry = evtObj.geometry; 
   
   // Point symbol
      var symbol = new SimpleMarkerSymbol(
     SimpleMarkerSymbol.STYLE_SQUARE,
  10,
  new SimpleLineSymbol(
    SimpleLineSymbol.STYLE_SOLID,
    new Color([255,0,0]),
    1),
  new Color([0,255,0,0.25])
   );
  
   // Add point to the map
      var graphic = new Graphic(geometry, symbol);
      app.map.graphics.add(graphic);

   // Store the point geometry
   list.push(geometry)
}

/*
    **  Create buffer around points
*/
function doBuffer() {
   // Stop drawing points
   app.tb.deactivate();

   // Show the zoom slider
      app.map.showZoomSlider();
  
      // Setup the buffer parameters
      var params = new BufferParameters();
      params.distances = [ dom.byId("distance").value ];
      params.bufferSpatialReference = new esri.SpatialReference({wkid: dom.byId("bufferSpatialReference").value});
      params.outSpatialReference = map.spatialReference;
      params.unit = GeometryService[dom.byId("unit").value];
   params.geometries = list;
  
   // Launch buffer calculation
      app.geo.buffer(params, showBuffer);
    };

/*
    **  Draw buffer on the map
*/
    function showBuffer(geoms) {
   // Symbol of the buffer
      var symbol = new SimpleFillSymbol(
        SimpleFillSymbol.STYLE_SOLID,
        new SimpleLineSymbol(
          SimpleLineSymbol.STYLE_SOLID,
          new Color([255,0,0,0.65]), 2
        ),
        new Color([255,0,0,0.35])
      );
     
   // Add the buffer graphics to the map
   array.forEach(geoms, function(geometry) {
        var graphic = new Graphic(geometry, symbol);
        app.map.graphics.add(graphic);
      });  
    }
 
    app = {
      map: map,
      tb: tb,
      geo: geo,
   buffer: doBuffer
    };
  });
 
  /*
  ** Click on Foggy Zone button
  */
  function foggyZoneClick(){
app.buffer();
  }
 
  /*
  ** Click on Point button
  */
  function pointClick(){
    app.tb.activate(esri.toolbars.Draw.POINT);
app.map.hideZoomSlider();
  }

Any help is appreciate (Its really urgent :( )

Outcomes