Browse Source

map_view: Fix zoom calculation for pixel snapping

Johannes Hofmann 7 years ago
parent
commit
18111f53e8
1 changed files with 2 additions and 4 deletions
  1. 2
    4
      src/map_view.rs

+ 2
- 4
src/map_view.rs View File

101
         let tile_screen_size = f64::powf(2.0, self.zoom - f64::from(uzoom)) * f64::from(self.tile_size);
101
         let tile_screen_size = f64::powf(2.0, self.zoom - f64::from(uzoom)) * f64::from(self.tile_size);
102
 
102
 
103
         if snap_to_pixel {
103
         if snap_to_pixel {
104
-            // only snap to pixel if apparent zoom is integer
105
-            let apparent_zoom = self.zoom + self.tile_zoom_offset;
106
-            let apparent_zoom_int = (apparent_zoom + 0.5).floor();
107
-            if (apparent_zoom - apparent_zoom_int).abs() < 1e-10 {
104
+            // only snap to pixel if zoom has integral value
105
+            if (self.zoom - (self.zoom + 0.5).floor()).abs() < 1e-10 {
108
                 top_left_tile_screen_coord.snap_to_pixel();
106
                 top_left_tile_screen_coord.snap_to_pixel();
109
             }
107
             }
110
         }
108
         }