Select to view content in your preferred language

SpatialReferende missing info causes endless loop in edit toolbar with textsymbol.

1332
5
04-28-2014 07:16 AM
SantoPfingsten
Deactivated User
Hello,

I have the following situation:
A map with a wkid of 31462 is using the edit toolbar.
When I try to resize a TextSymbol, it freezes. (high cpu usage, no response)

I've tracked it down to this:
In esri/toolbars/_Box.js _deNormalizePoint calls this._map._getFrameWidth() which returns -1.
It then does a loop that continues while Math.abs(...) >= -1, which obviously will never end.
map._getFrameWidth's problem is that it returns -1 if this.spatialReference._getInfo returns null and this.__LOD is not set.
spatialReference._getInfo checks the map spatialReference._info if it contains an entry for the wkid, which does not exist.

So my guess is that I need to add data for the wkid to the spatialReference._info array or add LOD data to the map.
Does anyone know what I might be missing ?
I'm not too deep into gis, and hours of googling did not find me any solution.
I'll try to put together a simple example to show the issue.

On a sidenote, the esri edit toolbar should not freeze the browser when there is no data available for a wkid.

Thanks
0 Kudos
5 Replies
JianHuang
Deactivated User
Santo,

It's been fixed for the next release.
0 Kudos
MelitaKennedy
Esri Notable Contributor
Can you change the wkid to its replacement, 31466? It's the same coordinate system, just a slightly different name.

Melita
0 Kudos
SantoPfingsten
Deactivated User
Thanks for the quick reply.
When will the next version be released ?
How can I work around the issue it until then ?

@Melita: I can't replace it in the map, and simply supplying a new SpatialReference object with the wkid does not seem to work.
But I don't see how that would work anyway, since the only wkids in the spatialReference._info map are: 3785, 3857, 4326, 102100,102113
0 Kudos
JianHuang
Deactivated User
I don't have access to the source code, but I still want to help because it was a bug of mine. Hopefully the workaround below would work.
when you create your application, require this module: "esri/toolbars/_Box", and replace the _deNormalizePoint function in the prototype.

require(["esri/toolbars/_Box",...other modules you need], function(Box, other module names){
  //you can check the source of the function _deNormalizePoint by examing the property 
  //Box.prototype._deNormalizePoint
  //once you have the minified code of the function, you can modify it as:
  Box.prototype._deNormalizePoint = function (d,a){
    //you add the following line of code
    if (this._map._getFrameWidth() === -1)return d;
  for(var b=this._map._getFrameWidth(),c={x:d.x,y:d.y};Math.abs(c.x-a.x)>=b;)c.x=c.x<a.x?c.x+b:c.x-b;var e=Math.abs(c.x-a.x);     Math.abs(c.x-a.x+b)<e?c.x+=b:Math.abs(c.x-a.x-b)<e&&(c.x-=b);return c
  };
  //the rest of your code of the application
});


http://jsfiddle.net/9PRdH/3/

Hope this helps.
0 Kudos
SantoPfingsten
Deactivated User
Thanks, that does solve the issue.
0 Kudos