AnsweredAssumed Answered

Javascript Error features[0].geometry.spatialReference.wkid

Question asked by bokeefe on Sep 11, 2014
Latest reply on Mar 17, 2015 by rscheitlin

So we've got an odd and anomalous situation going on.

 

We have two servers. One is TEST and one is DEV.

 

On the TEST server, the map works fine. It DID throw an error, but I added some TRY / CATCH to the mix and it solved the issue.

The EXACT same code was copied over to DEV (I know... going backwards, whole nother story) and suddenly it doesn't work.

 

The code in question that is throwing the error is:

 

var wkid = features[0].geometry.spatialReference.wkid;

 

Now, after this code there is a block of code with IF THEN / ELSE blocks that runs this:

 

function(feature)

{

     point = esri.geometry.geographicToWebMercator(feature.geometry);

     ( or point = feature.geometry; based on the WKID returned )

     point.attributes = feature.attributes;

     this._features.push(point);

}

 

The interesting thing is that on the TEST where this works, I added in some console.log calls with objToString (custom function) to print me out some human readable details and so I see all of the objects being sent to the screen. Now in DEV this SAME function, pulling same data, drops a javascript error alert window.

 

[object Error]

 

When you click the OK button it pauses and then proceeds to correctly fill the screen. So the code AFTER the WKID part runs like it's supposed to on TEST, but on DEV it throws that error... and then runs like it's supposed to. On TEST I was able to stop this kind of tom foolery by placing a TRY / CATCH and all goes as planned. But on DEV I still get the error.

 

Oh, on DEV (where the error is being thrown) I should note that I added a console.log call to objToString(features[0].geometry) and geometry is null. Yet after you click OK on the error window the dots fill the map?!?!?!

 

Confused.

Outcomes