Sha256: 87a38e19e0bf0492f94ab7a547f35a6829e01f293948fcddd6516ebc86ada2a7
Contents?: true
Size: 1.6 KB
Versions: 7
Compression:
Stored size: 1.6 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]], opacity: 0.75 }, 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); // Add initial bbox to map element for easier testing if (this.map.getBounds().isValid()) { this.element.setAttribute('data-js-map-render-bbox', this.map.getBounds().toBBoxString()); } this.map.addLayer(this.selectBasemap()); 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(); }, /** * Selects basemap if specified in data options, if not return positron. */ selectBasemap: function() { var _this = this; if (_this.data.basemap) { return GeoBlacklight.Basemaps[_this.data.basemap]; } else { return GeoBlacklight.Basemaps.positron; } } });
Version data entries
7 entries across 7 versions & 1 rubygems