Sha256: 5101d9a0c60a215847ced9b70e2e3591bcd600d61f29857cf788c5688da073e6

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

//= require geoblacklight/viewers/wms

GeoBlacklight.Viewer.Tilejson = GeoBlacklight.Viewer.Wms.extend({

  addPreviewLayer: function() {
    var _this = this;
    fetch(this.data.url).then(function(response) {
      if (!response.ok) {
          throw new Error("Unable to fetch tile.json document");
      }
      return response.json();
    }).then(function(tilejson) {
      var bounds = _this.getBounds(tilejson),
          options = bounds ? { bounds: bounds } : {},
          url = tilejson.tiles[0],
          tileJsonLayer = L.tileLayer(url, options);
      _this.overlay.addLayer(tileJsonLayer);
    }).catch(function(error) {
      console.debug(error);
    });
  },

  getBounds: function(doc) {
    // Get the bounds from the document, if they exist, and
    // convert to a Leaflet latlngBounds object
    var bounds = doc.bounds;
    if(bounds) {
      var corner1 = L.latLng(bounds[1], bounds[0]),
          corner2 = L.latLng(bounds[3], bounds[2]);
      return L.latLngBounds(corner1, corner2);
    }
  }
});

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
geoblacklight-4.4.2 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.4.1 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-3.8.1 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.4.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.4.0.rc1 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.3.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.2.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.1.1 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.1.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-3.8.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.0.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.0.0.pre.rc3 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-3.7.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.0.0.pre.rc2 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-4.0.0.pre.rc1 app/assets/javascripts/geoblacklight/viewers/tilejson.js
geoblacklight-3.6.0 app/assets/javascripts/geoblacklight/viewers/tilejson.js