Select to view content in your preferred language

Map Service Spatial Reference Incorrect

3966
15
Jump to solution
08-07-2014 10:25 AM
JoshObrecht
Regular Contributor

I am trying to add a map service into my application. The application has a spatial reference of 102100, as does the map service on the server. However when I add the service, it gets changed to 4326. Has anyone seen this issue previously and can give some insight?

0 Kudos
15 Replies
JoshObrecht
Regular Contributor

Here is what the addToMap function actually looks like. I accidentally removed a couple of pieces. Also when I set the extent, it goes to the middle of the ocean.

  function addToMap(idResults, evt) {

  var idResult;

  for (var i = 0, il = idResults.length; i < il; i++) {

  idResult = idResults.feature;

  }

  if (dijit.byId("val2").checked) {

  window.open("http://localhost/ST30_EDF_PDF/FB" + idResult.attributes.HUC_12 + ".pdf");

  }

  if (dijit.byId("val3").checked) {

  if (map.getLevel() > 5) {

  aspf = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost/server30/rest/services/acpf/MapServer", {

  visible : true

  });

  } else {

  aspf = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost/server30/rest/services/acpf/MapServer", {

  visible : false

  });

  }

  map.addLayer(aspf);

alert(aspf.spatialReference.wkid)

map.setExtent(aspf.initialExtent);

  legend.layerInfos.splice(1, 0, {

  layer : aspf,

  title : " ",

  autoToggle : false

  });

  legend.refresh();

  }

  }

  dojo.addOnLoad(init);

  });

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Josh,

   So the map service that http://localhost/server30/rest/services/acpf/MapServer‌ represents has a WKID of 102100? What does it's Initial Extent values actually look like when you view the Rest Service Directory page for this layer?

0 Kudos
JoshObrecht
Regular Contributor

Ok I can't explain this but it seems to be zooming properly now even though it still shows 4326. This I can deal with as that is all I was wanting it to do. If something breaks again, I'll get back to you.

0 Kudos
JoshObrecht
Regular Contributor

Ok this is interesting. Once I take the alert out, it reverts back to zooming into the ocean.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Josh,

   it sound like you need to wait for the layer to load before you set the maps extent.

0 Kudos
JoshObrecht
Regular Contributor

Yes! Can't believe I didn't think of that.

0 Kudos