map() issues with a temporary solution

I cannot see your code or how you used the map(...) function so I am left to guess that the problems that you had stem from the integer nature of the map(...) function.

You may have better luck implementing a floating point version of the map(...) function. The reference documentation for the map(...) function shows how it is implemented.

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

You may have better results by implementing a rounded floating point version of map(...). Of course, this will increase the memory usage due to the need for floating point library routines.

Not tested:

long mapRoundedFloat(long x, long in_min, long in_max, long out_min, long out_max)
{
  return long(float((x - in_min) * (out_max - out_min)) / float(in_max - in_min) + out_min + 0.5) ;
}

I believe that floating point arithmetic will be used due to the arithmetic rules of the C language.