Sha256: 09f79a3bf21bcb0b4fa29308dc9667329a21157737f830cc14fbbc2ee8e2475c

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

if(typeof jQuery == 'function') {
	jQuery.fn.populate_map = function() { 
		this.each(function() { build_map_and_markers(this); });
	};

  jQuery(function() {
    jQuery("#map_canvas").populate_map();
  });
}

function build_map_and_markers(element) {
  if (element != null) {
    var map = new google.maps.Map(element, {
      mapTypeId: google.maps.MapTypeId.<%= (Radiant::Config['event_map.googlemap.type'] || 'ROADMAP').upcase %>,
      mapTypeControlOptions: {
        style: google.maps.MapTypeControlStyle.<%= (Radiant::Config['event_map.googlemap.controlstyle'] || 'DROPDOWN_MENU').upcase %>
      }
    });
    var bounds = new google.maps.LatLngBounds();
  <% venues.each do |venue| %>
    <%- if venue.lat && venue.lng %>
      var location = new google.maps.LatLng("<%= venue.lat %>","<%= venue.lng %>")
      add_marker(map, {
        title : "<%= escape_javascript(venue.title) %>",
        position : location,
      <% if Radiant::Config['event_map.use_calendar_icons?'] && slug = slug_for_venue(venue) %>
        image : "/images/map_icons/<%= slug %>.png",
        shadow : "/images/map_icons/<%= slug %>_shadow.png",
      <% end %>
        description : "<%= escape_javascript(render :partial => 'venue', :object => venue) %>"
      });
      bounds.extend(location);
    <% end %>
  <% end %>
    map.fitBounds(bounds);
  }
}

function add_marker (map, mark) {
  var marker = new google.maps.Marker({ map : map, position : mark['position'], title : mark['title'], icon : mark['image'], shadow : mark['shadow'] });
  var infowindow = new google.maps.InfoWindow({ content : mark['description'] , maxWidth : 400 });
  google.maps.event.addListener(marker, 'click', function() { infowindow.open(map, marker); });
}






Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radiant-event_map-extension-1.3.2 app/views/event_venues/index.js.erb