Added max width and height calculations to the pop-up.
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 27 Aug 2018 19:43:48 +0000 (15:43 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 27 Aug 2018 19:46:38 +0000 (15:46 -0400)
views/front/members/list.html

index 9d986eb..e8efa55 100755 (executable)
                 });
               {/if}
 
+                var mapContainerWidth = Number(leafletMap._container.clientWidth);
+                var maxPopupWidth = .65 * mapContainerWidth;
+                if (maxPopupWidth > 600) {
+                    maxPopupWidth = 600;
+                }
+                var mapContainerHeight = Number(leafletMap._container.clientHeight);
+                var maxPopupHeight = .7 * mapContainerHeight;
 
               {foreach $mapItems as $m}
                 {if $m.lat != 0 && $m.lon != 0}
 
                 // Create marker for this member and and to Feature Group
                 var leafletMarker = L.marker([{$m.lat}, {$m.lon}], { title:  '{$m.member_name|escape:quotes}' })
-                    .bindPopup($('#map_info_' + {$m.id}).html())
+                    .bindPopup($('#map_info_' + {$m.id}).html(), {
+                        maxWidth: maxPopupWidth,
+                        maxHeight: maxPopupHeight
+                    })
                     .addTo(markerGroup);
 
             {/if}
 
                 leafletMap.on('popupopen', function(e) {
                     var px = leafletMap.project(e.popup._latlng);
-                    px.y -= e.popup._container.clientHeight/2;
+                    px.x -= 20;                                         // Bump a bit to the right to avoid resize buttons
+                    px.y -= e.popup._container.clientHeight/2;          // Position more toward the center
                     leafletMap.panTo(leafletMap.unproject(px),{ animate: true });
                 });