]> dev.renevier.net Git - syp.git/commitdiff
option to show popup near marker or on a corner
authorarno <arenevier@fdn.fr>
Sun, 16 Aug 2009 21:52:32 +0000 (23:52 +0200)
committerarno <arenevier@fdn.fr>
Thu, 20 Aug 2009 08:36:35 +0000 (10:36 +0200)
Now, it's possible to set the popup on one of the four corners instead
of just bottom right one.

inc/html/index.php
inc/settings.php.in
js/syp.js

index 8382159b0686a9f5ff0c04c50b7e20c84e381e3f..5de0a53497bb05650d9a294cdfe5f4e6dd3bc674 100644 (file)
@@ -16,10 +16,10 @@ if (defined ("THUMBSMAXSIZE") && (THUMBSMAXSIZE > 0)) {
     $thumbsmaxsize = 400; // default value;
 }
 
-if (defined ("POPUPNEARFEATURE") && (POPUPNEARFEATURE)) {
-    $popupnearfeature = true;
+if (defined ("POPUPPOS")) {
+    $popuppos = POPUPPOS;
 } else {
-    $popupnearfeature = false;
+    $popuppos = 3;
 }
 ?>
 <html lang="<?php echo $lang?>">
@@ -52,7 +52,7 @@ if (defined ("POPUPNEARFEATURE") && (POPUPNEARFEATURE)) {
             noImageRegistered: "<?php ptrans('There is no image registered on this site.')?>"
         };
         var sypSettings =  {
-            popupNearfeature: <?php printf ($popupnearfeature ? "true": "false")?>
+            popupPos: <?php printf ($popuppos)?>
         };
     </script>
     <script src="./openlayers/OpenLayers.js" type="text/javascript"></script>
index 5d4910a7b4d6f253dfb4fc583f21fb204b538dce..ed12c5f4d9de94ddae06623ed58d7a2c8fc0cee6 100644 (file)
@@ -47,7 +47,10 @@ define ("THUMBSDIRURL", "");
 // uploaded image is bigger, images will be resized.
 define ("THUMBSMAXSIZE", 400);
 
-// if set to 0 (default), popup will appear at bottom right corner of the map.
-// If set to 1 or true, popup will appear near marker.
-define ("POPUPNEARFEATURE", 0);
+// If set to 0 popup will appear near selected marker. 
+// If set to 1, popup will appear at top left corner of the map
+// If set to 2, popup will appear at top right corner of the map
+// If set to 3 (default), popup will appear at bottom right corner of the map
+// If set to 4, popup will appear at bottom left corner of the map
+define ("POPUPPOS", 3);
 ?>
index 40735c791cbb516ea273c0fe40a0e85d58ecb28b..c3613873523bb999d0e220a896c81de7d7127475 100644 (file)
--- a/js/syp.js
+++ b/js/syp.js
@@ -184,10 +184,25 @@ var SYP = {
         var popup = feature.popup;
 
         var popupPos = null;
-        if (sypSettings.popupNearfeature) {
-            popupPos = feature.geometry.getBounds().getCenterLonLat();
-        } else {
-            popupPos = SYP.Utils.brCorner(map, 8);
+        switch (sypSettings.popupPos) {
+            case 0:
+                popupPos = feature.geometry.getBounds().getCenterLonLat();
+            break;
+            case 1:
+                popupPos = SYP.Utils.tlCorner(map, 8);
+            break;
+            case 2:
+                popupPos = SYP.Utils.trCorner(map, 8);
+            break;
+            case 3:
+                popupPos = SYP.Utils.brCorner(map, 8);
+            break;
+            case 4:
+                popupPos = SYP.Utils.blCorner(map, 8);
+            break;
+            default:
+                popupPos = SYP.Utils.brCorner(map, 8);
+           break;
         }
 
         // we cannot reuse popup; we need to recreate it in order for IE
@@ -263,13 +278,36 @@ var SYP = {
     },
 
     Utils: {
+        tlCorner: function(map, margin) {
+            var bounds = map.calculateBounds();
+            var corner = new OpenLayers.LonLat(bounds.left, bounds.top);
+            var cornerAsPx = map.getPixelFromLonLat(corner);
+            cornerAsPx = cornerAsPx.add( +margin, +margin);
+            return map.getLonLatFromPixel(cornerAsPx);
+        },
+
+        trCorner: function(map, margin) {
+            var bounds = map.calculateBounds();
+            var corner = new OpenLayers.LonLat(bounds.right, bounds.top);
+            var cornerAsPx = map.getPixelFromLonLat(corner);
+            cornerAsPx = cornerAsPx.add( -margin, +margin);
+            return map.getLonLatFromPixel(cornerAsPx);
+        },
+
         brCorner: function(map, margin) {
             var bounds = map.calculateBounds();
             var corner = new OpenLayers.LonLat(bounds.right, bounds.bottom);
             var cornerAsPx = map.getPixelFromLonLat(corner);
             cornerAsPx = cornerAsPx.add( -margin, -margin);
-            corner = map.getLonLatFromPixel(cornerAsPx);
-            return corner;
+            return map.getLonLatFromPixel(cornerAsPx);
+        },
+
+        blCorner: function(map, margin) {
+            var bounds = map.calculateBounds();
+            var corner = new OpenLayers.LonLat(bounds.left, bounds.bottom);
+            var cornerAsPx = map.getPixelFromLonLat(corner);
+            cornerAsPx = cornerAsPx.add( +margin, -margin);
+            return map.getLonLatFromPixel(cornerAsPx);
         },
 
         /* minimum bounds rectangle containing all feature locations.