Parcourir la source

Allow movement of the crosshair in the main windows

Samuel il y a 8 ans
Parent
commit
bc9984df7f
1 fichiers modifiés avec 10 ajouts et 3 suppressions
  1. 10 3
      panorama/templates/panorama/main.html

+ 10 - 3
panorama/templates/panorama/main.html

@@ -116,8 +116,10 @@
             });
             });
         }
         }
         function fillCoord() {
         function fillCoord() {
-            var lat = map.getCenter().lat.toFixed(5);
-            var lng = map.getCenter().lng.toFixed(5);
+            //var lat = map.getCenter().lat.toFixed(5);
+            //var lng = map.getCenter().lng.toFixed(5);
+            var lat = crosshair.getLatLng().lat.toFixed(5);
+            var lng = crosshair.getLatLng().lng.toFixed(5);
             $('#id_custompoint-latitude').val(lat);
             $('#id_custompoint-latitude').val(lat);
             $('#id_newpano-latitude').val(lat);
             $('#id_newpano-latitude').val(lat);
             $('#id_newrefpoint-latitude').val(lat);
             $('#id_newrefpoint-latitude').val(lat);
@@ -195,7 +197,7 @@
             map.addLayer(osm);
             map.addLayer(osm);
     
     
             // Add in a crosshair for the map
             // Add in a crosshair for the map
-            crosshair = new L.marker(map.getCenter(), {clickable:false,icon:crosshairIcon});
+            crosshair = new L.marker(map.getCenter(),{icon:crosshairIcon,draggable:true});
             crosshair.addTo(map);
             crosshair.addTo(map);
     
     
             // Move the crosshair to the center of the map when the user pans
             // Move the crosshair to the center of the map when the user pans
@@ -209,6 +211,11 @@
                     fillCoord();
                     fillCoord();
                 }
                 }
             });
             });
+            crosshair.on('moveend', function(e) {
+                if ($("#locate-gps,#new-pano,#new-refpoint").hasClass("collapse in")){
+                    fillCoord();
+                }
+            });
             $('#locate-gps-btn, #new-pano-btn, #new-refpoint-btn').click(function(e) {
             $('#locate-gps-btn, #new-pano-btn, #new-refpoint-btn').click(function(e) {
                 fillCoord();
                 fillCoord();
             });
             });