AnsweredAssumed Answered

Displaying Points on Different Projections

Question asked by on Feb 3, 2017
Latest reply on Feb 7, 2017 by MKennedy-esristaff

I'm trying to do something very simple and can not seem to figure out what the problem is.  I have a REST service that retrieves locations with decimal lat/long's.  I want to add a point to a map for each of these locations.  As long as the spatial reference is 4326, everything is fine.  If I try to add points in any other spatial reference, they are added incorrectly.  Specifically, I am trying to add points to a 102021 projection (Antarctica).  Even when I set the map's spatial reference to 102021 and use a layer whose projection is defined as 102021, and specify 102021 as the spatial reference in my Point constructor, the points are not added to the correct locations.  Through various attempts, I have been able to get the correct projection with the wrong points, the correct points on the wrong projection, and the wrong projection with the wrong points.  All other resources have shown this to be a fairly easy task, but I am at a loss as to why this isn't working, and any help would be greatly appreciated.  Code snippet below.


var map;

function(Point, Extent, GeometryService, ProjectParameters, SpatialReference, SimpleMarkerSymbol, Graphic, Color, ArcGISDynamicMapServiceLayer,
ArcGISTiledMapServiceLayer, Map, parser, xhr, Array, webMercUtils)
gsvc = new GeometryService("");
params = new ProjectParameters();

// a map layer defined as 102021
var antarcLayer = new ArcGISDynamicMapServiceLayer("");
var symbol = new SimpleMarkerSymbol();
symbol.setColor(new Color("#00FFFF"));


// coords are passed in
map = new Map("mapDiv", {
   extent: new Extent({
   xmin: <%=minX%>,
   ymin: <%=minY%>,
   xmax: <%=maxX%>,
   ymax: <%=maxY%>,
   spatialReference:{wkid: 102021}

// I have tried webMercatorUtils to convert from geometry to mercator and back and lat/long to xy and back, and these do not work either
// I have also tried using Geometry Service "project"
   xhr("<rest_url>", {
   method: "GET",
   handleAs: "json"
     Array.forEach(jsonData, function(entry,i){
     console.log(entry.platformId + "," + entry.latitude + "," + entry.longitude + " at index " + i );
     var pt = new Point(entry.longitude, entry.latitude, new SpatialReference(102021)); Graphic(pt, symbol));

<body class="claro">
<div id="mapDiv"></div>