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

3219
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

Make sure you remove the outSR from your esriRequest.

0 Kudos
BehrouzHosseini
Occasional Contributor

Ok Here is a better answer:

Hard- coding  and adding a Point like DD is working 

var point = new Point(-88.1681599642482, 41.796253348566786);
var pointGraphic = new esri.Graphic(point);
 graphicsLayerTraceNetworkJunctions.add(pointGraphic);‍‍‍

But same point in Meter Unit not displaying on the map

 var point = new Point(-9814834.6714, 5130507.876800001);
 var pointGraphic = new esri.Graphic(point);
 graphicsLayerTraceNetworkJunctions.add(pointGraphic);‍‍‍

and as you can see I am getting all point in Meter!

0 Kudos
KevinAndras
New Contributor II

I'm having the same exact problem.  I am copying point geometries from a featurelayer in WebMercator, and putting the points into graphics and adding that to the map.  The featurelayer points show up just fine.  The graphic points only show up if I override the x/y values with lat-long coordinates. I've been trying to use this:

var point2 = webMercatorUtils.webMercatorToGeographic(point.geometry),

but that throws this error: "Cannot read property 'clone' of undefined".

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kevin,


   What is the class type of the point?

Point.geometry would mean to me that poin is a graphic is that correct.

0 Kudos
KevinAndras
New Contributor II

I figured it out.  Original points were generic type "point".  webMercatorToGeographic did not work, but xyToLngLat did.  Don't understand why, but for now my problem is solved:


for (var i = 0; i < response.features.length; i++) {
   textSymbol.text = response.features.attributes.Origin

   var point = {
      type: "point",
      x: response.features.geometry.x,
      y: response.features.geometry.y
   }
   var newXY = webMercatorUtils.xyToLngLat(point.x, point.y)
   var point2 = {
      type: "point",
      x: newXY[0],
      y: newXY[1]
   }
   var pointGraphic = new Graphic({
      geometry: point2,
      symbol: textSymbol
   });
   GLCopy.graphics.add(pointGraphic);
};

//after all graphics are added:

map.add(GLCopy); 

0 Kudos