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?
Solved! Go to Solution.
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);
});
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?
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.
Ok this is interesting. Once I take the alert out, it reverts back to zooming into the ocean.
Josh,
it sound like you need to wait for the layer to load before you set the maps extent.
Yes! Can't believe I didn't think of that.