Sha256: f54b1608116e2a4eb9c2520664587727de93293996ee74cbbfd1ec8cdc98407b

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 KB

Contents

//= require geoblacklight/viewers/viewer

GeoBlacklight.Viewer.Map = GeoBlacklight.Viewer.extend({

  options: {
    /**
    * Initial bounds of map
    * @type {L.LatLngBounds}
    */
    bbox: [[-80, -195], [80, 185]]
  },

  basemap: L.tileLayer(
    'https://otile{s}-s.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
      attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="//developer.mapquest.com/content/osm/mq_logo.png" alt="">',
      maxZoom: 18,
      worldCopyJump: true,
      subdomains: '1234' // see http://developer.mapquest.com/web/products/open/map
    }
  ),

  overlay: L.layerGroup(),

  load: function() {
    if (this.data.mapBbox) {
      this.options.bbox = L.bboxToBounds(this.data.mapBbox);
    }
    this.map = L.map(this.element).fitBounds(this.options.bbox);
    this.map.addLayer(this.basemap);
    this.map.addLayer(this.overlay);
    if (this.data.map !== 'index') {
      this.addBoundsOverlay(this.options.bbox);
    }
  },

  /**
   * Add a bounding box overlay to map.
   * @param {L.LatLngBounds} bounds Leaflet LatLngBounds
   */
  addBoundsOverlay: function(bounds) {
    if (bounds instanceof L.LatLngBounds) {
      this.overlay.addLayer(L.polygon([
        bounds.getSouthWest(),
        bounds.getSouthEast(),
        bounds.getNorthEast(),
        bounds.getNorthWest()
      ]));
    }
  },

  /**
   * Remove bounding box overlay from map.
   */
  removeBoundsOverlay: function() {
    this.overlay.clearLayers();
  }
});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geoblacklight-0.9.2 app/assets/javascripts/geoblacklight/viewers/map.js
geoblacklight-0.9.1 app/assets/javascripts/geoblacklight/viewers/map.js
geoblacklight-0.9.0 app/assets/javascripts/geoblacklight/viewers/map.js
geoblacklight-0.8.0 app/assets/javascripts/geoblacklight/viewers/map.js
geoblacklight-0.7.1 app/assets/javascripts/geoblacklight/viewers/map.js
geoblacklight-0.7.0 app/assets/javascripts/geoblacklight/viewers/map.js