OpenScales + Flex 3.x map right positions solution

2012-03-27

I am using OpenScales on Flex SDK 3.x. Using Mapnik layer, placing markers on map. But the problem was, that markers are placed at wrong position (checking with google maps) by given Longitude/Latitude. And that is not only problem. At different zoom rates (especially most detailed) that position changes.

Googled, read documentation, found hints that it is known problem ... "due to freeZoom with tiled layers". Tried different projections, calculate shift on map, but it was changing depending on center and zoom level. After few days tried again and failed to fix. After week tested again OpenScales examples and they work perfectly! How can it be, that my map works wrong, but examples even in my program work correctly??!!

The problem was in generating resolutions. Mapnik layer had initially good resolutions, after calling


mapnik.generateResolutions(18);


they are different and in fact wrong. Feature layers added get initially wrong resolutions. They are very close, but still different (1.1943285667419434 vs 1.1943885320738488; 4891.969809375 vs 4892.2154273744845).

The solution was to provide correct 'nominalResolution' parameter:


mapnik.generateResolutions(18, OSM.DEFAULT_MAX_RESOLUTION);


Now my map is zoomed correctly and markers placed on correct places.

Hope someday someone will google to my solution and save few hours or week for solving similar problem.

Please do not ask questions, why I am working on old technologies Flex SDK 3.x and OpenScales v1.1.8. :o)