]> dev.renevier.net Git - syp.git/commitdiff
option to show popup near marker
authorarno <arenevier@fdn.fr>
Sat, 8 Aug 2009 10:59:55 +0000 (12:59 +0200)
committerarno <arenevier@fdn.fr>
Sat, 8 Aug 2009 10:59:55 +0000 (12:59 +0200)
inc/settings.php
inc/templates_index.php
js/syp.js

index 50797f0eafc9e932324834ae7dcf33c158ab6547..5d4910a7b4d6f253dfb4fc583f21fb204b538dce 100644 (file)
@@ -46,4 +46,8 @@ define ("THUMBSDIRURL", "");
 // max size (either width or height) of thumbnails. If one dimension of
 // 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);
 ?>
index 722daa9479bbdbe7a1ec1d087c4d2d558d162260..9f54d3b0b93e7d3703f59f4daad95b9db8f1a87d 100644 (file)
@@ -49,6 +49,12 @@ if (defined ("THUMBSMAXSIZE") && (THUMBSMAXSIZE > 0)) {
         <?php
             printf ("var sypOrig = [%.18F, %.18F, %.18F, %.18F];\n",
                     $bbox [0], $bbox [1], $bbox [2], $bbox [3]);
+
+            if (defined ("POPUPNEARFEATURE") && (POPUPNEARFEATURE)) {
+                printf ("var sypPopupNearFeature = true;\n");
+            } else {
+                printf ("var sypPopupNearFeature = false;\n");
+            }
         ?>
     </script>
     <script src="./openlayers/OpenLayers.js" type="text/javascript"></script>
index cf92ef51f9601ba8fa48478b62f51467736e4109..2c87c2b34bb83b64ae8fe784d9558f2343d519d8 100644 (file)
--- a/js/syp.js
+++ b/js/syp.js
@@ -169,7 +169,12 @@ var SYP = {
         }
         var popup = feature.popup;
 
-        var brCorner = SYP.Utils.brCorner(map, 8);
+        var popupPos = null;
+        if (sypPopupNearFeature) {
+            popupPos = feature.geometry.getBounds().getCenterLonLat();
+        } else {
+            popupPos = SYP.Utils.brCorner(map, 8);
+        }
 
         // we cannot reuse popup; we need to recreate it in order for IE
         // expressions to work. Otherwise, we get a 0x0 image on second view.
@@ -189,7 +194,7 @@ var SYP = {
             this.map.events.register("movestart", this, this._unselect = function () { this.unselect(feature)});
             return;
         }
-        popup = SYP.createPopup(brCorner, contentHTML);
+        popup = SYP.createPopup(popupPos, contentHTML);
         var control = this;
         popup.hide = function () {
             OpenLayers.Element.hide(this.div);