KapoorVashisht / osmdroid

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

Allow floating point ("in-between") zoom levels. #460

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Right now our zoom levels are integers. When we pinch-to-zoom we can scale the 
imagery to emulate "in-between" zoom levels but once we end the gesture it will 
snap back to a "fixed" integer zoom level. We do not allow the users to pan the 
maps while in an "in-between" zoom level. This causes a less-seamless 
experience as the maps "snap" to predefined zoom levels.

It would be nice to allow the user to pinch-to-zoom and stay in one of the 
"in-between" zoom levels. To do this we would need to:

1. Return a float for getZoomLevel(). This is a breaking change unless we leave 
the existing methods (deprecated) for backwards compatibility.
2. Remove the code that snaps pinch-to-zoom operations to integer zoom levels. 
Store the floating point zoom level.
3. Change the dispatchDraw() method to scale the tiles appropriately. Something 
like scale = (1 + (floor(mZoomLevel) - mZoomLevel));

This would provide a seamless experience as you zoom in and out of the maps.

Original issue reported on code.google.com by kurtzm...@gmail.com on 7 Aug 2013 at 2:30

GoogleCodeExporter commented 8 years ago
Attaching a patch that mostly works.

Original comment by kurtzm...@gmail.com on 7 Aug 2013 at 9:11

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by kurtzm...@gmail.com on 2 Sep 2013 at 3:28

GoogleCodeExporter commented 8 years ago

Original comment by kurtzm...@gmail.com on 3 Sep 2013 at 8:32

GoogleCodeExporter commented 8 years ago
I am trying to apply this patch. I did a

svn up -r1284

followed by:

(from 
/home/doriad/src/osmdroid-read-only/osmdroid-android/src/main/java/org/osmdroid)
:

patch -p0 < ~/FloatZoomLevelPatch.patch

but I get a ton of errors (see below). Any suggestions?

Thanks,

David

(Stripping trailing CRs from patch.)                                            

patching file api/IMapController.java                                           

Hunk #1 FAILED at 13.                                                           

1 out of 1 hunk FAILED -- saving rejects to file api/IMapController.java.rej    

(Stripping trailing CRs from patch.)                                            

patching file api/IMapView.java                                                 

Hunk #1 FAILED at 13.                                                           

1 out of 1 hunk FAILED -- saving rejects to file api/IMapView.java.rej          

(Stripping trailing CRs from patch.)                                            

patching file events/ZoomEvent.java                                             

Hunk #1 FAILED at 9.                                                            

Hunk #2 FAILED at 26.                                                           

2 out of 2 hunks FAILED -- saving rejects to file events/ZoomEvent.java.rej     

(Stripping trailing CRs from patch.)                                            

patching file views/MapController.java                                          

(Stripping trailing CRs from patch.)                                            

patching file views/MapView.java                                                

Hunk #1 FAILED at 78.                                                           

Hunk #2 FAILED at 250.                                                          

Hunk #3 FAILED at 308.                                                          

Hunk #4 FAILED at 332.                                                          

Hunk #5 FAILED at 347.                                                          

Hunk #6 FAILED at 372.                                                          

Hunk #7 FAILED at 381.                                                          

Hunk #8 FAILED at 425.                                                          

Hunk #9 FAILED at 515.                                                          

Hunk #10 FAILED at 545.                                                         

Hunk #11 FAILED at 572.                                                         

Hunk #12 FAILED at 981.                                                         

Hunk #13 FAILED at 996.                                                         

Hunk #14 FAILED at 1052.                                                        

Hunk #15 FAILED at 1152.                                                        

Hunk #16 FAILED at 1169.                                                        

Hunk #17 FAILED at 1187.                                                        

Hunk #18 FAILED at 1277.                                                        

Hunk #19 FAILED at 1297.                                                        

Hunk #20 FAILED at 1353.                                                        

Hunk #21 FAILED at 1377.                                                        

Hunk #22 FAILED at 1425.                                                        

Hunk #23 FAILED at 1440.                                                        

Hunk #24 FAILED at 1490.                                                        

Hunk #25 FAILED at 1531.                                                        

25 out of 25 hunks FAILED -- saving rejects to file views/MapView.java.rej      

(Stripping trailing CRs from patch.)                                            

patching file views/overlay/MinimapOverlay.java                                 

Hunk #1 FAILED at 140.                                                          

Hunk #2 FAILED at 181.                                                          

2 out of 2 hunks FAILED -- saving rejects to file 
views/overlay/MinimapOverlay.java.rej                                
(Stripping trailing CRs from patch.)                                            

patching file views/overlay/mylocation/MyLocationNewOverlay.java                

Hunk #1 FAILED at 166.                                                          

Hunk #2 FAILED at 418.                                                          

Hunk #3 FAILED at 435.                                                          

3 out of 3 hunks FAILED -- saving rejects to file 
views/overlay/mylocation/MyLocationNewOverlay.java.rej               
(Stripping trailing CRs from patch.)                                            

patching file views/overlay/MyLocationOverlay.java                              

Hunk #1 FAILED at 249.                                                          

Hunk #2 FAILED at 396.                                                          

Hunk #3 FAILED at 410.                                                          

3 out of 3 hunks FAILED -- saving rejects to file 
views/overlay/MyLocationOverlay.java.rej                             
(Stripping trailing CRs from patch.)                                            

patching file views/overlay/ScaleBarOverlay.java                                

(Stripping trailing CRs from patch.)                                            

patching file views/overlay/TilesOverlay.java                                   

(Stripping trailing CRs from patch.)                                            

patching file views/util/PathProjection.java                                    

Hunk #1 FAILED at 32.                                                           

Hunk #2 FAILED at 46.                                                           

2 out of 2 hunks FAILED -- saving rejects to file 
views/util/PathProjection.java.rej            

Original comment by daviddo...@gmail.com on 9 Sep 2013 at 12:46

GoogleCodeExporter commented 8 years ago
This patch doesn't work when it comes to, for example, converting screen 
coordinates to the map coordinates. The problem is in the calculation of the 
map size, and this method in the TileSystem class:

    public static int MapSize(final int levelOfDetail) {
        return mTileSize << (int) levelOfDetail;
    }

Does anyone have an idea how can we calculate the map size for the floating 
point zoom levels?

Original comment by gencic.n...@gmail.com on 16 Dec 2013 at 7:47

GoogleCodeExporter commented 8 years ago
This should calculate the correct size. Note that I didn't test it myself.

public static int MapSize(final float levelOfDetail) {
  int levelOfDetailFloor = Math.floor(levelOfDetail);
  return (mTileSize << levelOfDetailFloor )*(levelOfDetail-levelOfDetailFloor+1);
}

Original comment by innovap...@gmail.com on 10 Feb 2014 at 7:22

GoogleCodeExporter commented 8 years ago
In the patch I found the following line:
final float newZoomLevel = Math.max(minZoomLevel, Math.min(maxZoomLevel, 
aZoomLevel));

Why do you limit the zoom to maxZoomLevel? Wouldn't it be nice to let the user 
zoom further in than zoom-levels available?

Original comment by innovap...@gmail.com on 10 Feb 2014 at 7:25

GoogleCodeExporter commented 8 years ago
Thanks for the hint, I'll give it a try. There was a bug when panning the map - 
it wasn't moving correctly on the floating-point zoom levels. For example - set 
the zoom level to something like 17.5, put your finger over the location 
overlay, and pan the map - the overlay won't stay bellow the finger.

Original comment by gencic.n...@gmail.com on 10 Feb 2014 at 7:29

GoogleCodeExporter commented 8 years ago
Hi Marc, 

Is this feature planned for the next osmdroid release? This would be great.

Note that in the MapBox fork of osmdroid, there is a work in progress on this 
subject - this may help. 

The link to the commit: 
https://github.com/Akylas/mapbox-android-sdk/commit/1940ab1d0e39b992ac9dd451c2f8
ae34efee9777

Original comment by mathieu....@gmail.com on 13 Mar 2014 at 11:23