How to Specify Out Unit to Be in Decimal Degree in JS API

3225
34
11-29-2017 03:53 PM
BehrouzHosseini
Occasional Contributor

I am using a Map service on ARcGIS Server 10.4.1 which is in this format

Spatial Reference: 102100  (3857) 
Single Fused Map Cache: false 
Initial Extent:

      XMin: -9819759.37726215
      YMin: 5128008.078704429
      XMax: -9809084.764440382
      YMax: 5132626.115644935
      Spatial Reference: 102100  (3857)

Full Extent:

      XMin: -9819004.6505
      YMin: 5125535.589900002
      XMax: -9809349.0802
      YMax: 5131992.668099999
      Spatial Reference: 102100  (3857)

 

Units: esriMeters 

Now when I query the service it returns the data in Meter format which I can not display back them on the map as new graphics. Can you please let me know how I can change the service configuration or OutUnit in ArcGIS JavaScript API to be in Decimal Degree

0 Kudos
34 Replies
RobertScheitlin__GISP
MVP Emeritus

Bengi,

   Add this line of code somewhere after the map is created:

console.info(map.spatialReference.wkid);

0 Kudos
BehrouzHosseini
Occasional Contributor

I am getting error on this

Uncaught TypeError: Cannot read property 'wkid' of undefined

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bengi,

   Then you are putting it before the map is ready.

0 Kudos
BehrouzHosseini
Occasional Contributor

Ok the output is this:

102100

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bengi,

   The the data is returning in the correct WKID and you don't need to change it.

See if the changes I made to lines 7 and 18 help your issue.

 var edgesResultFeatures = result.edges;
 console.log(edgesResultFeatures);
 var edgeGraphics;
 for (var j = 0, jl = edgesResultFeatures.length; j < jl; j++) {
   var featureSet = edgesResultFeatures[j].features;
   for (var i = 0, il = featureSet.length; i < il; i++) {
     edgeGraphics = new esri.Graphic(featureSet[i].geometry)
     graphicsLayerTraceNetworkEdges.add(edgeGraphics);
   }
 }
 
 var junctionsResultFeatures = result.junctions;
 console.log(junctionsResultFeatures);
 var junctionsGraphics;
 for (var j = 0, jl = junctionsResultFeatures.length; j < jl; j++) {
   var featureSet = junctionsResultFeatures[j].features;
   for (var i = 0, il = featureSet.length; i < il; i++) {
     junctionsGraphics = new esri.Graphic(featureSet[i].geometry);
     graphicsLayerTraceNetworkJunctions.add(junctionsGraphics);
   }
 }
0 Kudos
BehrouzHosseini
Occasional Contributor

same! nothing on the Map! but on console!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bengi,

 Try adding line 7 below and share the console results with me.

var edgesResultFeatures = result.edges;
 console.log(edgesResultFeatures);
 var edgeGraphics;
 for (var j = 0, jl = edgesResultFeatures.length; j < jl; j++) {
   var featureSet = edgesResultFeatures[j].features;
   for (var i = 0, il = featureSet.length; i < il; i++) {
     console.log(featureSet[i]);
     edgeGraphics = new esri.Graphic(featureSet[i].geometry)
     graphicsLayerTraceNetworkEdges.add(edgeGraphics);
   }
 }
 
 var junctionsResultFeatures = result.junctions;
 console.log(junctionsResultFeatures);
 var junctionsGraphics;
 for (var j = 0, jl = junctionsResultFeatures.length; j < jl; j++) {
   var featureSet = junctionsResultFeatures[j].features;
   for (var i = 0, il = featureSet.length; i < il; i++) {
     junctionsGraphics = new esri.Graphic(featureSet[i].geometry);
     graphicsLayerTraceNetworkJunctions.add(junctionsGraphics);
   }
 }
0 Kudos
BehrouzHosseini
Occasional Contributor

There you are:

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bengi,

  The value is already a graphic so you should try this:

var edgesResultFeatures = result.edges;
 console.log(edgesResultFeatures);
 var edgeGraphics;
 for (var j = 0, jl = edgesResultFeatures.length; j < jl; j++) {
   var featureSet = edgesResultFeatures[j].features;
   for (var i = 0, il = featureSet.length; i < il; i++) {
     //edgeGraphics = new esri.Graphic(featureSet.geometry)
     graphicsLayerTraceNetworkEdges.add(featureSet[i]);
   }
 }
 
 var junctionsResultFeatures = result.junctions;
 console.log(junctionsResultFeatures);
 var junctionsGraphics;
 for (var j = 0, jl = junctionsResultFeatures.length; j < jl; j++) {
   var featureSet = junctionsResultFeatures[j].features;
   for (var i = 0, il = featureSet.length; i < il; i++) {
     //junctionsGraphics = new esri.Graphic(featureSet.geometry);
     graphicsLayerTraceNetworkJunctions.add(featureSet[i]);
   }
 }
0 Kudos
BehrouzHosseini
Occasional Contributor

I am afraid but still not working!

0 Kudos