AnsweredAssumed Answered

Geometry cannot be converted to spatial reference of the map

Question asked by jbcbirder on Aug 25, 2014
Latest reply on Aug 26, 2014 by jbcbirder

Please help me if you can,

I'm getting the following message in the console ...

Map: Geometry (wkid: 102685) cannot be converted to spatial reference of the map (wkid: 102100)


Similar to this thread


I also found this one which appears related

Map options: issues with non-mercator spatial reference 


I tried using the suggestion by Adam Skoog in that first thread (66936) but when I get to what shows up as line # 07. In his code, I get an error as follows:

Uncaught TypeError: Cannot read property 'spatialReference' of undefined


Which seems odd since all of this is inside a require block that includes Map, ProjectParameters, SpatialReference, Extent, Geometry, GeometryService etc. etc.


My code looks like this = "/proxy"; = false;

    esriConfig.defaults.geometryService = new GeometryService("");


// I have xMin, xMax, yMin, yMax sent in to this php file and it seems I need the Number() fx to get real numbers

// This prints the following to the console ...

// -8819410.666559163 4792613.494165327 -8813596.67509507 4794481.424044095 pmeasure.js:50

// -8816503.670827117 4793547.459104711 pmeasure.js:51


// Uncaught TypeError: Cannot read property 'spatialReference' of undefined



    var avgX = ((Number(xMin) + Number(xMax)) / 2);

    var avgY = ((Number(yMin) + Number(yMax)) / 2);



    console.log(xMin, yMin, xMax, yMax);

    console.log(avgX, avgY);

    var passedExtent = new esri.geometry.Extent(Number(xMin), Number(yMin), Number(xMax), Number(yMax), new esri.SpatialReference({wkid:102685}) );

    var projectParams = new esri.tasks.ProjectParameters();

    projectParams.geometries = passedExtent;

    projectParams.outSR = new esri.SpatialReference({wkid:102100}); // map.spatialReference;  ummmmm map not defined yet

    projectParams.spatialReference = new esri.SpatialReference({wkid:2248}); // map.spatialReference;


    // var defer = esri.config.defaults.geometryService.project(projectParams);

    // dojo.when(defer, function (projectedGeometry) {

    //   if (projectedGeometry.length > 0) {

    //     map.setExtent(projectedGeometry[0]);

    //   }

    // });


    map = new Map("map", {

      basemap: "streets",

      center: [avgX, avgY], // center: [-79.23, 39.51],

      extent: passedExtent,

      zoom: 12