Sha256: 636a79e6a8e8c4147a10fb52d3ccff78228a99ff5edaf273f910d311e751a93d
Contents?: true
Size: 1.6 KB
Versions: 12
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: [[-82, -144], [77, 161]], 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
12 entries across 12 versions & 1 rubygems