change toLocal and toGlobal with mapPixelToCoords and mapCoordsToPixel