Position of features (PointFeature or CustomMarker) change during zooming

176 views
Skip to first unread message

Joey van Dijk

unread,
Mar 1, 2012, 9:39:58 AM3/1/12
to opensca...@googlegroups.com
After some time figuring out how Openscales works with "features" (POI = Point of Interest) I keep having issues with the positions of these features after zooming in or out.
To zoom I use

map.zoomIn(); OR map.zoomOut();

and below you can see the code 

const MERCATOR_PROJECTION:String = "EPSG:900913";
const NORMAL_PROJECTION:String = "EPSG:4326"

//create map
map = new Map();
map.name = 'map';
map.size = new Size(1200, 700);
map.projection = MERCATOR_PROJECTION;
map.backTileColor = Palette.MAP_BACKGROUND;
map.defaultZoomInFactor = 0.5;
map.defaultZoomOutFactor = 2;
map.restrictedExtent = new Bounds(541000,6865000,548000,6870000,MERCATOR_PROJECTION);

//add geo-layer
mapLayer = new Mapnik('Mapnik');
mapLayer.displayedName = 'base';
mapLayer.projection = MERCATOR_PROJECTION;
mapLayer.generateResolutions(18, OSM.DEFAULT_MAX_RESOLUTION);
mapLayer.buffer = 1;
map.addLayer(mapLayer);

//define borders of zooming
map.maxResolution = new Resolution(mapLayer.resolutions[0],mapLayer.projection);
map.minResolution = new Resolution(mapLayer.resolutions[mapLayer.resolutions.length-1],mapLayer.projection);

//some controls
var mp:MousePosition = new MousePosition(new Pixel(0,0));
mp.displayProjection = MERCATOR_PROJECTION;
mp.prefix = 'Current: ';
mp.x = 250;
mp.y = 10;
map.addControl(mp);
map.addControl(new DragHandler());
map.addControl(new WheelHandler());
addChild(map);

//create the markers
markers = new VectorLayer("markerLayer");
markers.projection = MERCATOR_PROJECTION;
markers.generateResolutions(17, OSM.DEFAULT_MAX_RESOLUTION);
markers.style = Style.getDefaultPointStyle();

//add the first marker
var loca:Location = new Location(4.905,52.371,NORMAL_PROJECTION);
loca = loca.reprojectTo(new ProjProjection(MERCATOR_PROJECTION));]
var marker:PointFeature = PointFeature.createPointFeature(loca,null,Style.getDefaultCircleStyle());
markers.addFeature(marker);

//add a second marker
loca = new Location(4.902,52.37,NORMAL_PROJECTION);
loca = loca.reprojectTo(new ProjProjection(MERCATOR_PROJECTION));
marker = PointFeature.createPointFeature(loca);
markers.addFeature(marker);

//add marker with different symbol
loca = new Location(4.9,52.37149,NORMAL_PROJECTION);
loca = loca.reprojectTo(new ProjProjection(MERCATOR_PROJECTION));
var mark:CustomMarker = CustomMarker.createUrlBasedMarker("add_placemark.png",loca);
markers.addFeature(mark);

//add features-layer to map
map.addLayer(markers);

It looks like that the current resolution does not match any of the generated resolutions and therefore some kind of miscalculation forces the "features" to "move" around after zooming.
I have tried many "solutions" I found at this group but I have set the projections of the map, geo-layer and markers/features-layer to the same projection (MERCATOR).

I am really missing simple Openstreetmaps-example with "features" on top of it with a specific area to focus on (for example Amsterdam). This is really helpful to get a good insight how to move from Google Maps for Flash to Openscales.

Can anyone reproduce the "moving features"? And does anyone has an idea about what could be wrong? map.restrictedExtent? or something else? Would appreciate your help.

Joey van Dijk

unread,
Mar 2, 2012, 5:18:54 AM3/2/12
to opensca...@googlegroups.com
I have to say that these issues are most visible at the maximum zoomlevels (=16/17/18). I am using Openscales 2.1.1 but POI/features are still not sticking on their lat/lon position.

Let me know if you need more information.

Op donderdag 1 maart 2012 15:39:58 UTC+1 schreef Joey van Dijk het volgende:

WillPetty

unread,
Mar 2, 2012, 9:18:45 AM3/2/12
to opensca...@googlegroups.com
do you have the same problem if you create the points with MERCATOR_PROJECTION" instead of the normal projection and then re-projecting the location?

-Will

WillPetty

unread,
Mar 2, 2012, 9:28:10 AM3/2/12
to opensca...@googlegroups.com
 also if its happening only at the highest zoom levels, could it be this issue ? : http://groups.google.com/group/openscales-dev/browse_thread/thread/735234b06e5a7488/8caaa3b5d7a28a05?lnk=gst&q=OS+2.0+Mapnik+layer+shifting#8caaa3b5d7a28a05

-Will




On Friday, March 2, 2012 9:18:45 AM UTC-5, WillPetty wrote:
do you have the same problem if you create the points with MERCATOR_PROJECTION" instead of the normal projection and then re-projecting the location?

-Will

ur help.


Joey van Dijk

unread,
Mar 5, 2012, 3:35:40 AM3/5/12
to opensca...@googlegroups.com
Yup, 

when using

var loca:Location = new Location(4.902,52.37,NORMAL_PROJECTION);
loca = loca.reprojectTo(new ProjProjection(MERCATOR_PROJECTION));

it is giving me the same issues.
Will have a look at your next suggestion.

Joey



Op vrijdag 2 maart 2012 15:18:45 UTC+1 schreef WillPetty het volgende:

Joey van Dijk

unread,
Mar 5, 2012, 3:49:16 AM3/5/12
to opensca...@googlegroups.com
As you see in my code above, I am using the tips provided by the post:

- use mercator projection everywhere (map, OSM-layer, and markers)
- use "generateResolutions(.." to generate correct resolutions
- set correct tileOrigin by mapLayer.origin = new Location(-20037508.34, 20037508.34, MERCATOR_PROJECTION);

but all of them together are not solving my issue that my markers/features are shifting when at maximum zoom levels.

It is kind of frustrating while all other functionality I needed is working with OpenScales, but apparantly the shift from Google Maps is tricky. Like with Mapquest, the lack of examples to specific options provided by the lib (Openscales/Mapquest) makes it time-consuming and difficult to use these new libs. But also the documentation is really basic, none of the functions describe what they do exactly OR/AND describe their boundaries AND/OR best practices what to avoid (call certain function at start and not at the end of your process).

Any other suggestions or a fix would be very welcome to come back to Openscales as my standard library to use with maps.

Thnx for the tips Will.

Joey

PS: I have thought that it had to do with my own tiles that I was using, but changing the mapLayer.proxy = "http://openscales.org/proxy.php?url=" is showing the same issues of shifting, no change.

Op vrijdag 2 maart 2012 15:28:10 UTC+1 schreef WillPetty het volgende:
Op vrijdag 2 maart 2012 15:28:10 UTC+1 schreef WillPetty het volgende:

Op vrijdag 2 maart 2012 15:28:10 UTC+1 schreef WillPetty het volgende:
Reply all
Reply to author
Forward
0 new messages