eventsmanager

Location map clustering

Aug 13th, 2014
588
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×