AnsweredAssumed Answered

Map options: issues with non-mercator spatial reference

Question asked by odoe on Jun 5, 2013
Latest reply on Jun 6, 2013 by odoe
I've been having trouble trying to load a map in a spatial reference wkid of 26915.
I've tried a couple of different ways.
I load a map without any basemaps and then add an ImageService that has a wkid of 26915.
    require([       'esri/map',       'esri/layers/ArcGISImageServiceLayer'       ], function(Map, ArcGISImageServiceLayer) {       var map = new Map('map', {             autoResize: true,             center: [762120.3983057996, 4286928.371310163],             scale: 2888.131627324678            }),       imgurl = 'http://moimagery.missouri.edu/arcgis/rest/services/LGov/EWGateway2012_6inch/ImageServer';       map.addLayers([new ArcGISImageServiceLayer(imgurl)]);       map.on('click', function() {         console.debug('MAP CENTER: ', map.extent.getCenter());         console.debug('MAP SCALE: ', map.getScale());       });     });

I get a console message like so:
Map: Geometry (wkid: 4326) cannot be converted to spatial reference of the map (wkid: 26915) 

But my map is not where it should be.
If you open the debug console of your browser and click on the map, you can see the center and scale are not as expected.

I even tried explicitly defining the spatial reference of the map in the map options.
    require([       'esri/map',       'esri/layers/ArcGISImageServiceLayer',       'esri/SpatialReference'       ], function(Map, ArcGISImageServiceLayer, SR) {       var map = new Map('map', {             autoResize: true,             spatialReference: new SR({wkid:26915}),             center: [762120.3983057996, 4286928.371310163],             scale: 2888.131627324678            }),       imgurl = 'http://moimagery.missouri.edu/arcgis/rest/services/LGov/EWGateway2012_6inch/ImageServer';       map.addLayers([new ArcGISImageServiceLayer(imgurl)]);       map.on('click', function() {         console.debug('MAP CENTER: ', map.extent.getCenter());         console.debug('MAP SCALE: ', map.getScale());       });     });


You can run a sample of this here;
http://plnkr.co/edit/lUXpEIfdpMToCYGzMK4R

Again, checking the console, these numbers don't match.

If I don't set the scale, it will just default to the full extent of the service.

This does work if I explicitly define an extent like this:
    require([       'esri/map',       'esri/layers/ArcGISImageServiceLayer',       'esri/SpatialReference',       'esri/geometry/Extent'       ], function(Map, ArcGISImageServiceLayer, SpatialReference, Extent) {       var ext = new Extent(689690.1735286616, 4231176.807089917, 739306.7413302765, 4256822.370572377, new SpatialReference({wkid: 26915})),            map = new Map('map', {             autoResize: true,             extent: ext           }),       imgurl = 'http://moimagery.missouri.edu/arcgis/rest/services/LGov/EWGateway2012_6inch/ImageServer';       map.addLayers([new ArcGISImageServiceLayer(imgurl)]);     });

http://plnkr.co/edit/LqpDulsrKhGYEH3QRS3H?p=preview

So the map is using the SpatialReference of the extent to set itself up properly, but doesn't seem to like having a SpatialReference set and use the center option like I was trying to do above.

Am I missing something? The map reference for the center option doesn't say it has to be in wkid: 4326.
http://developers.arcgis.com/en/javascript/jsapi/map-amd.html#map1

edit, because it does say array containing longitude and latitude in the docs, so yeah, that implies I can only use the center option if using a web mercator map that it could convert the lat/longs from. That kinda blows, I'll just have to go with extents in this case.

Outcomes