I making a web app in Flex using global coordinates
I get the coordinates as strings from a web service then I do something like this:
latStr:String = "28.7242100786401";
longStr:String = "-106.12635420984";
var cLat:Number = new Number(latStr);
var cLong:Number = new Number(longStr);
This works PERFECT on IE and chrome, from the web server and when debugging locally, but Firefox just works when debugging locally and not from the web server, in the web server cLat
and cLong
return "NaN
".
check it out yourself, it should pop up an alert when you click on a result: http://mundobuk.com/prueba/mapa/main.html?buscar=oxxo
so I tried using parseFloat()
, but it rounds cLat
to 28
and cLong
to -106
:(
Then I tried separating the decimals form integers, like from my example 28 and 7242100786401 then divide 7242100786401/10000000000000 = 0.7242100786401
having 2 numbers 28 and 0.7242100786401 I add them up
28 + 0.7242100786401 = 28.7242100786401
here is in code form:
var latArr:Array = latStr.split(".");
var longArr:Array = longStr.split(".");
var latDivStr:String = "1";
for (var i:int= 0; i< latArr[1].length; i++){
latDivStr += "0";
}
var longDivStr:String = "1";
for (var j:int = 0; j< longArr[1].length; j++){
longDivStr += "0";
}
var cLat:Number = parseFloat(latArr[0]) + arseFloat(latArr[1])/parseFloat(latDivStr);
var cLong:Number = parseFloat(longArr[0]) - parseFloat(longArr[1])/parseFloat(longDivStr);
again, this way works great everywhere, just not in firefox in the web server >_>
anyone have any ideas? im going crazy whit this @_@