zulkic / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Icons disappear when scrolling over intl. date line #345

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add an icon to the map west of and close to the international date line, for 
example something in New Zealand (MyLocationOverlay is affected in the same way 
if you happen to be in that area).
2. Scroll the visible map so that the international date line is appearing on 
the right hand side of the visible map
3. The icon will disappear

What is the expected output? What do you see instead?
All icons should be visible if included in visible map area.

What version of the product are you using? On what operating system?
3.0.8

Please provide any additional information below.

The problem occurs when the MapView spans more than 1 single world size, i.e. 
the MapView longitudinal range spans the world twice or more times. The method 
toMapPixels() puts the result point on the rightmost copy of the world - which 
is not always visible.

The fix is simply to subtract the world map size from the longitude if the 
point then is still right of the left boundary of the view port:

        public Point toMapPixels(final IGeoPoint in, final Point reuse) {
            final Point out = reuse != null ? reuse : new Point();

            TileSystem.LatLongToPixelXY(in.getLatitudeE6() / 1E6, in.getLongitudeE6() / 1E6,
                    getZoomLevel(), out);
            out.offset(offsetX, offsetY);
            if (out.x - TileSystem.MapSize(getZoomLevel()) >= getScrollX() - getWidth() / 2) {
                out.x -= TileSystem.MapSize(getZoomLevel());
            }
            return out;
        }

Original issue reported on code.google.com by osei...@gmail.com on 20 May 2012 at 10:34

Attachments:

GoogleCodeExporter commented 9 years ago
See also issue 239 and issue 285.

Original comment by neilboyd on 21 May 2012 at 8:04

GoogleCodeExporter commented 9 years ago
Actually there is a slightly smarter fix for this. Firstly the problem can also 
effect the latitudinal part of the coordinate as well and secondly in some 
circumstances icons got moved to the right in a non-smooth way when scrolling.

This approach tries to keep the icon on the closest possible position to the 
map centre:
        public Point toMapPixels(final IGeoPoint in, final Point reuse) {
            final Point out = reuse != null ? reuse : new Point();
            TileSystem.LatLongToPixelXY(in.getLatitudeE6() / 1E6, in.getLongitudeE6() / 1E6,
                    getZoomLevel(), out);
            out.offset(offsetX, offsetY);
            if (Math.abs(out.x - getScrollX()) > Math.abs(out.x
                    - TileSystem.MapSize(getZoomLevel()) - getScrollX())) {
                out.x -= TileSystem.MapSize(getZoomLevel());
            }
            if (Math.abs(out.y - getScrollY()) > Math.abs(out.y
                    - TileSystem.MapSize(getZoomLevel()) - getScrollY())) {
                out.y -= TileSystem.MapSize(getZoomLevel());
            }
            return out;
        }

Original comment by osei...@gmail.com on 23 May 2012 at 7:22

GoogleCodeExporter commented 9 years ago
Issue 285 has been merged into this issue.

Original comment by neilboyd on 24 May 2012 at 7:38

GoogleCodeExporter commented 9 years ago
Issue 239 has been merged into this issue.

Original comment by neilboyd on 24 May 2012 at 7:38

GoogleCodeExporter commented 9 years ago
Thanks for the patch.

Original comment by neilboyd on 24 May 2012 at 7:39

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1101.

Original comment by neilboyd on 24 May 2012 at 7:51

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thanks for reopening this as items east of dateline still disappear when map 
center is west of dateline.

link to issue 364

Original comment by manim...@gmail.com on 24 Aug 2012 at 5:36

GoogleCodeExporter commented 9 years ago
A small extension of my previous patch will fix this also for objects east of 
the date line.

Original comment by osei...@gmail.com on 10 Oct 2012 at 8:02

Attachments:

GoogleCodeExporter commented 9 years ago
The last path was applied in revision 1363.

Original comment by neilboyd on 10 Oct 2013 at 6:57