Browse Source

Bug fix when clicked outside the image_cap_max.

Samuel 8 years ago
parent
commit
77435eb49c
2 changed files with 12 additions and 2 deletions
  1. 11 2
      panorama/static/panorama/js/pano.js
  2. 1 0
      panorama/templates/panorama/view.html

+ 11 - 2
panorama/static/panorama/js/pano.js

@@ -1254,13 +1254,22 @@ function load_map(){
         var a = Math.acos( Math.cos(lat_ref) * Math.cos(phi - phi_ref) * Math.cos(lat) + Math.sin(lat_ref) * Math.sin(lat) );
         // azimuth between the ref_point and the clic_point (=new cap)
         var B = Math.asin( Math.sin(phi - phi_ref) * Math.sin(Math.PI/2 - lat)/Math.sin(a));
-        // little hack because asin give an angle in [-pi/2, pi/2] 
+        // little hack because asin give an angle in [-pi/2, pi/2] and we want
+        // in [0 360]
         if (lat>lat_ref){   
             var newCap = toDeg(B);
         } else {
             var newCap = toDeg(Math.PI-B);
         }
-
+        if (newCap < 0 ){
+            newCap += 360;
+        }
+        // cap_min < cap < cap_max
+        if (newCap < image_cap_min){
+            newCap = image_cap_min;
+        } else if (newCap > image_cap_max){
+            newCap = image_cap_max;
+        }
         // change the cap
         angle_control = document.getElementById('angle_ctrl');
         angle_control.value = newCap;

+ 1 - 0
panorama/templates/panorama/view.html

@@ -103,6 +103,7 @@
       {% endfor %}
 
       $( document ).ready(load_map);
+
     </script>
 {% endlocalize %}
 {% endblock js %}