GP service

3185
32
Jump to solution
08-19-2015 08:37 AM
TerryGustafson
Occasional Contributor II

I'm trying to use a gp service to return a point and values from a gp service and can't seem to get the define point to return.  Can anyone help?

<!DOCTYPE html>
<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>Geometry Service: Relation</title>

   
<link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">

   
<style>
     
html, body, #mapDiv {
       
height: 100%;
       
margin: 0;
       
padding: 0;
       
width: 100%;
     
}
     
#info {
        bottom: 20px;
       
color: #444;
       
height: auto;
       
font-family: arial;
       
left: 20px;
       
margin: 5px;
       
padding: 10px;
       
position: absolute;
       
text-align: left;
       
width: 200px;
       
z-index: 40;
     
}
     
.label {
       
display: inline-block;
       
width: 4em;
     
}
   
</style>
  
   
<script src="http://js.arcgis.com/3.14compact/"></script>

   
<script>
   
     
   
var map, gp;
   
     
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,
       
config, Request) {
       
       
       
var geometryService, geometries, baseGraphics;

       
map = new esri.Map("mapDiv", {
         
basemap: "topo",
         
center: [-111.185, 46.052],
         
zoom: 15
       
});
       
       
map.on("click", executeGP);
       
       
gp = new Geoprocessor("http://app.mdt.mt.gov/arcgis/rest/services/LRS/LocateFeaturesOnDCandRM/GPServer/Locate%20features%20...");
       
       
gp.setOutputSpatialReference({
           
wkid: 102100       
       
       
})
       
     
      
       
       
function executeGP(run){
           
map.graphics.clear();
           
var pointSymbol = new SimpleMarkerSymbol();
           
pointSymbol.setSize(14);
           
pointSymbol.setOutline(new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1));
           
pointSymbol.setColor(new Color([0, 255, 0, 0.25]));
           
           
var graphic = new Graphic(run.mapPoint, pointSymbol);
           
map.graphics.add(graphic);
           
           
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
            };
           
           
gp.submitJob(params, processGP);
           
           
function processGP(jobInfo){   
           
gp.getResultData(jobInfo.jobId, "LRM_DC_RM_MI1", renderResult);
           
           
};
           
           
function renderResult(result, message){
           
alert(result);
           
};
           
   
</script>

 
</head>

 
<body class="claro">
   
<div id="mapDiv"></div>
   
<div id="LatLng" >
       
Enter the lat/long:
       
   
</div>
 
</body>
</html>

0 Kudos
32 Replies
TerryGustafson
Occasional Contributor II

Robert,

I tried that but I can’t seem to get it to work.. Do you have a second to look at it?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Terry,

   No, I am in the middle of migrating all my widgets I have made available to the public, over to WAB 1.2.

Here is the doc link for the project method

You can also glean code from custom widget that are available on GeoNet (like Tim's Location widget).

TerryGustafson
Occasional Contributor II

Robert,

Thanks for all of your help, I was able to get the widget working correctly..  Thanks for your patience.

0 Kudos