Skip to content

Commit

Permalink
issue planetfederal#230 - WMS and TMS preview image enhancements (use…
Browse files Browse the repository at this point in the history
… scaled image for WMS-attribution and tile preview images)
  • Loading branch information
justb4 committed Apr 14, 2014
1 parent 18dd44b commit 229b2e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/script/plugins/AddLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,10 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, {
// TODO: background image loading, and loading only once
var previewImageURL = source.getPreviewImageURL(record, layerPreviewWidth, layerPreviewHeight);
if (previewImageURL) {
data.previewImage = '<div style="width:' + layerPreviewWidth + 'px; height:'+ layerPreviewHeight + 'px; background-image: url(\'' + previewImageURL + '\'); background-repeat: repeat;" >&nbsp;</div>';
// Only resize TMS preview images. TODO: make smarter an request from Source
var backgroundSize = record.data.scalePreviewImage === true ? 'background-size:' + layerPreviewWidth + 'px ' + layerPreviewHeight + 'px;' : ' ';

data.previewImage = '<div style="width:' + layerPreviewWidth + 'px; height:'+ layerPreviewHeight + 'px; background-image: url(\'' + previewImageURL + '\'); ' + backgroundSize + ' background-repeat: repeat;" >&nbsp;</div>';
// data.previewImage = '<img class="layerpreview" width="'+ layerPreviewWidth +'" height="'+ layerPreviewHeight + '" src="' + previewImageURL + '"/>';
} else {
data.previewImage = '<div style="width:' + layerPreviewHeight + 'px; height:'+ layerPreviewHeight + 'px" class="preview-notavailable">&nbsp;</div>';
Expand Down
5 changes: 4 additions & 1 deletion src/script/plugins/TMSSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ gxp.data.TMSCapabilitiesReader = Ext.extend(Ext.data.DataReader, {
name: data.title,
"abstract": abstrct,
tileMapUrl: this.meta.baseUrl,
scalePreviewImage: true,
group: this.meta.group
}));
}
Expand All @@ -99,6 +100,7 @@ gxp.data.TMSCapabilitiesReader = Ext.extend(Ext.data.DataReader, {
name: tileMap.title,
"abstract": abstrct,
tileMapUrl: url,
scalePreviewImage: true,
group: this.meta.group
}));
}
Expand Down Expand Up @@ -233,7 +235,8 @@ gxp.plugins.TMSSource = Ext.extend(gxp.plugins.LayerSource, {
});
this.target.createLayerRecord({
source: this.id,
name: config.name
name: config.name,
scalePreviewImage: true
}, callback, scope);
},
scope: this
Expand Down
2 changes: 2 additions & 0 deletions src/script/plugins/WMSSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,11 @@ gxp.plugins.WMSSource = Ext.extend(gxp.plugins.LayerSource, {
// var url = layerURL + 'REQUEST=GetMap&VERSION=1.1.1&SRS=EPSG:4326&BBOX=' + bbox + '&FORMAT=' + layerFormat + '&WIDTH=' + width + '&HEIGHT=' + height + '&LAYERS=' + layerName+layerScaleStr;

var url;
record.data.scalePreviewImage = false;
if (this.owsPreviewStrategies.indexOf('attributionlogo') >= 0 && record.data.attribution && record.data.attribution.logo && record.data.attribution.logo.href) {
// Use attribution logo a preview image
url = record.data.attribution.logo.href;
record.data.scalePreviewImage = true;
}

if (!url && this.owsPreviewStrategies.indexOf('getlegendgraphic') >= 0 ) {
Expand Down

0 comments on commit 229b2e4

Please sign in to comment.