SHARE
TWEET

Location map clustering

eventsmanager Aug 13th, 2014 461 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--- START --->
  2. <!---
  3. 1. go to your theme header.php (or create a separate javascript file and include it)
  4.  
  5. 2. paste the snippet below your header.php wp_head() code
  6.  
  7. 3. you can now use EM shortcode [locations_map]
  8. --->
  9. <!---  END  --->
  10.  
  11. <script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js"></script>  
  12. <script>
  13.                
  14.         jQuery(document).bind('em_maps_locations_hook', function( e, maps, data ){
  15.  
  16.                  var markers = [];
  17.                
  18.                 for (var i = 0; i < data.length; i++) {
  19.                          if( !(data[i].location_latitude == 0 && data[i].location_longitude == 0) ){
  20.                                 var latitude = parseFloat( data[i].location_latitude );
  21.                                 var longitude = parseFloat( data[i].location_longitude );
  22.                                 var latLng = new google.maps.LatLng(latitude, longitude);
  23.                                 var marker = new google.maps.Marker({'position': latLng});
  24.                                 markers.push(marker);
  25.                         }
  26.                 }                      
  27.                
  28.                 var markerCluster = new MarkerClusterer(maps, markers);
  29.  
  30.         });
  31.  
  32. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top