Select to view content in your preferred language

First attempt at using a geoprocessing service in a js web app

4936
11
Jump to solution
02-25-2015 09:42 AM
ChrisRomsos
Deactivated User

Hi,

I'm a novice web developer and have run into a snag and am not sure how to proceed.

Objective:  create a simple web viewer using the javascript API for arc gis server.  Create a button in the application that triggers an asynchronous geoprocessing service and adds the output as a dynamic map layer.

Progress: Using the example code on the ESRI webpages I quickly re-deployed the basic js example of a web app that loads a dynamic map service.  Next, I read the online help related to using a geoprocessing service in a web app and displaying the results here.

ArcGIS Help 10.1 ‌"using"

and here

ArcGIS Help 10.1  "displaying"

Note: the geoprocessing service works when I test it from arcmap etc.

I'm not sure if I should post code directly to this message or not, so instead I'll put a link to the site.  Then view source should reveal the code.

Link to non functional app

Thanks, Chris

0 Kudos
11 Replies
TimWitt2
MVP Alum

This is where you tell the WebApp builder what files your widget uses via the properties.

Check out this document if you want to start developing: Web AppBuilder Developer Edition - Customization Resource List

TerryGustafson
Frequent Contributor

Ok , I make some progress but still can’t figure out why this will not go to the define coordinates.. Any ideas?











html, body, #mapDiv

#info

.label





var map;

var APP = {};

require([

"dojo/dom", "dojo/_base/array", "dojo/promise/all", "dojo/json",

"esri/map", "esri/domUtils", "esri/graphic", "esri/graphicsUtils",

"esri/geometry/Point", "esri/SpatialReference", "esri/tasks/GeometryService", "esri/tasks/Geoprocessor",

"esri/tasks/FeatureSet", "esri/tasks/RelationParameters",

"esri/Color", "esri/symbols/SimpleLineSymbol",

"esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleFillSymbol",

"esri/config", "esri/request", "dojo/domReady!"

], function(

dom, array, all, JSON,

Map, domUtils, Graphic, graphicsUtils,

Point, SpatialReference, GeometryService, Geoprocessor,

FeatureSet, RelationParameters,

Color, SimpleLineSymbol,

SimpleMarkerSymbol, SimpleFillSymbol,

esriConfig, esriRequest

) {

var geometryService, geometries, baseGraphics;

map = new esri.Map("mapDiv", {

basemap: "topo",

center: ,

zoom: 15

});

map.on("click", executeGP);

var gpUrl = "http://app.mdt.mt.gov/arcgis/rest/services/LRS/LocateFeaturesOnDCandRM/GPServer/Locate%20features%20along%20DC%20and%20RM";

APP.geoprocessor = new Geoprocessor(gpUrl);

function executeGP(){

var point = new Point(-12180856.426452411, 5952832.259593694, new SpatialReference({ wkid: 102100 }));

//var geometry = new geometry();

var graphic = new Graphic(point);

var features = [];

var featureSet = new FeatureSet();

featureSet.features = features;

var params = {

"f": "json",

"outSR": 102100,

"City_Centers" : featureSet,/**{

"geometryType":"esriGeometryPoint",

"features": [{

"geometry": {

"x": -12180856.426452411,

"y": 5952832.259593694,

"spatialReference":{

"wkid": 102100

}

}

}],

"sr": {

"wkid": 102100

}

},**/

"Search_Radius": {

"distance":50,

"units":"esriFeet"

},

"Keep_only_closest_route_location": false

//'distance_field': true,

//'zero_length_events': true,

//'in_fields': true,

//'m_direction_offsetting': true

};

APP.geoprocessor.submitJob(params, processGP);

};

function processGP(jobInfo){

APP.geoprocessor.getResultData(jobInfo.jobId, "LRM_DC_RM_MI1", renderResult);

};

function renderResult(result, message){

alert(result);

};

});








Enter the lat/long:



0 Kudos