Sha256: b1832f7402e8b60e26441ccf04daa7fb0ea1aa6db26415d43aef12383d083b49

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

<script type="text/javascript">
    var map;

    function addPoints(data) {
      var markers_data = [];
      if (data.length > 0) {
         for (var i = 0; i < data.length; i++) {
           markers_data.push({
              lat: data[i].lat,
              lng: data[i].lon,
              title: data[i].title,
              icon: data[i].icon,
              infoWindow: {
                content: data[i].popup_html
              },
           });
         }
      }

      map.addMarkers(markers_data);
    }

    $(document).ready(function(){
      infoWindow = new google.maps.InfoWindow({});
      map = new GMaps({
        div: '#main_map',
        zoom: <%= @map_view[:zoom] %>,
        lat: <%= @map_view[:lat] %>,
        lng: <%= @map_view[:lon] %>,
        <% if @map[:cluster] %>
          markerClusterer: function(map) {
            options = {
              gridSize: <%= @map.fetch(:cluster_grid_size, 40) %>,
              minimumClusterSize: <%= @map.fetch(:cluster_minumum_size, 2) %>,
              zoomOnClick: <%= @map.fetch(:cluster_zoom_on_click, true) %>
            };

            return new MarkerClusterer(map, [], options);
          }
        <% end %>
      });

      points = $.getJSON("/points/json");
      points.done(addPoints);
    });
</script>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
travlrmap-0.0.13 views/_map_js.erb
travlrmap-0.0.12 views/_map_js.erb