More marker magic for member list maps
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Mar 2015 20:06:52 +0000 (16:06 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Mar 2015 20:06:52 +0000 (16:06 -0400)
views/front/members/list.html

index b9ca45a..b1cbd77 100644 (file)
     {if $haveMembers}
         {foreach $members as $m}
 
+            // Create a marker for this member
             var marker = new google.maps.Marker({  
                 map: map,  
                 position: new google.maps.LatLng({$m.lat}, {$m.lon}),
-                draggable: true,
+                draggable: false,
                 animation: google.maps.Animation.DROP,  
                 title: "{$m.member}",
                 memberID: {$m.id}
             });
             
+            // Add a click listener for this marker
+            marker.addListener('click', function() {
+               markerSelected(this);
+            });
+            
+            // Extend the map bounds to include this marker
             bounds.extend(marker.position);
+            
         {/foreach}
     {/if}
 
-            map.fitBounds(bounds);
-        
-            google.maps.event.addListener(marker, 'click', function() {
+            // Marker click events - Send to detail page
+            function markerSelected(t) {
                 window.location.replace("{$thisURL}?action=detail&member=" + this.memberID);
-            });
+            }
 
+            // Fit map to bounds of all markers
+            map.fitBounds(bounds);
+        
 
         });
     </script>