Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions R/addGeoRaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ imagequeryOptions <- function(className = "info legend",
type = c("mousemove", "click"),
digits = NULL,
prefix = "Layer",
noData = "NoData Value") {
noData = "NoData Value",
suffix = "") {
type = match.arg(type)
position <- match.arg(position)
list(
Expand All @@ -450,7 +451,8 @@ imagequeryOptions <- function(className = "info legend",
type = type,
digits = digits,
prefix = prefix,
noData = noData
noData = noData,
suffix = suffix
)
}

Expand Down
5 changes: 4 additions & 1 deletion R/imagequery.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#' @param prefix a character string to be shown as prefix for the layerId.
#' @param className a character string to append to the control legend.
#' @param ... currently not used.
#' @param suffix a character string to be shown as suffix for the layerId values.
#'
#' @return
#' A leaflet map object.
Expand Down Expand Up @@ -63,7 +64,8 @@ addImageQuery = function(map,
position = 'topright',
prefix = 'Layer',
className = "",
...) {
...,
suffix = "") {

if (inherits(map, "mapview")) map = mapview2leaflet(map)

Expand Down Expand Up @@ -157,6 +159,7 @@ addImageQuery = function(map,
, type
, digits
, prefix
, suffix
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function mouseHandler(map, georaster, layerId, group, eventName, options) {
val[0] = options.noData
}
if (query) {
outputWidget.innerHTML = renderInfo(val, layerId, options.digits, options.prefix);
outputWidget.innerHTML = renderInfo(val, layerId, options.digits, options.prefix, options.suffix);
}
let eventInfo = $.extend({
id: layerId,
Expand All @@ -43,13 +43,13 @@ function mouseHandler(map, georaster, layerId, group, eventName, options) {
}
};
}
function renderInfo(val, layerId, digits, prefix) {
function renderInfo(val, layerId, digits, prefix, suffix) {
$(document.getElementById("rasterValues-" + layerId)).show();
let text = "";
if(digits === "null" || digits === null) {
text = "<small>"+ prefix+ " <strong>"+ layerId + ": </strong>"+ val + "</small>";
text = "<small>"+ prefix+ " <strong>"+ layerId + ": </strong>"+ val + (suffix.startsWith(" ") ? suffix : " " + suffix) + "</small>";
} else {
text = "<small>"+ prefix+ " <strong>"+ layerId + ": </strong>"+ val[0].toFixed(digits)+ "</small>";
text = "<small>"+ prefix+ " <strong>"+ layerId + ": </strong>"+ val[0].toFixed(digits) + (suffix.startsWith(" ") ? suffix : " " + suffix) + "</small>";
}
return text;
}
Expand Down
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/joda/addImageQuery-bindings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global LeafletWidget, $, L */
LeafletWidget.methods.addImageQuery = function(layerId, bounds, type, digits, prefix) {
LeafletWidget.methods.addImageQuery = function(layerId, bounds, type, digits, prefix, suffix) {
(function(){
var map = this;

Expand Down Expand Up @@ -29,7 +29,7 @@ LeafletWidget.methods.addImageQuery = function(layerId, bounds, type, digits, pr
if (!(map.layerManager.getVisibleGroups().includes(layerId))) {
visible = false;
}
rasterPicker.pick(e, layerId, boundsarr, digits, prefix, visible);
rasterPicker.pick(e, layerId, boundsarr, digits, prefix, suffix, visible);
});
}).call(this);
};
Expand Down
10 changes: 5 additions & 5 deletions inst/htmlwidgets/lib/joda/joda.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rasterPicker.old = function(e, x, data) {
}
};

rasterPicker.pick = function(event, layerId, bounds, digits, prefix, visible) {
rasterPicker.pick = function(event, layerId, bounds, digits, prefix, suffix, visible) {
var outputWidget = this.getInfoLegend(layerId);
if (!visible) {
$(outputWidget).hide();
Expand All @@ -49,7 +49,7 @@ rasterPicker.pick = function(event, layerId, bounds, digits, prefix, visible) {
pickedLayerData[rasterHitInfo.layerId] = this.getLayerData(rasterHitInfo, event.latlng /*, event.zoom?*/);
}
// render collected hit values
outputWidget.innerHTML = this.renderInfo(pickedLayerData, digits, prefix);
outputWidget.innerHTML = this.renderInfo(pickedLayerData, digits, prefix, suffix);
};

rasterPicker.getInfoLegend = function(layerId) {
Expand Down Expand Up @@ -116,7 +116,7 @@ rasterPicker.getLayerData = function(rasterHitInfo, latlng, zoom) {
return layerData;
};

rasterPicker.renderInfo = function(pickedLayerData, digits, prefix) {
rasterPicker.renderInfo = function(pickedLayerData, digits, prefix, suffix) {
var text = "";
for (var layer_key in pickedLayerData) {
var layer = pickedLayerData[layer_key];
Expand All @@ -126,9 +126,9 @@ rasterPicker.renderInfo = function(pickedLayerData, digits, prefix) {
$(document.getElementById("imageValues" + "-" + layer_key)).show();
}
if(digits === "null" || digits === null) {
text += "<small>"+ prefix+ " <strong>"+ layer.layerId + ": </strong>"+ layer.value+ "</small>";
text += "<small>"+ prefix+ " <strong>"+ layer.layerId + ": </strong>"+ layer.value+ (suffix.startsWith(" ") ? suffix : " " + suffix) + "</small>";
} else {
text += "<small>"+ prefix+ " <strong>"+ layer.layerId + ": </strong>"+ layer.value.toFixed(digits)+ "</small>";
text += "<small>"+ prefix+ " <strong>"+ layer.layerId + ": </strong>"+ layer.value.toFixed(digits)+ (suffix.startsWith(" ") ? suffix : " " + suffix) + "</small>";
}
}
return text;
Expand Down
5 changes: 4 additions & 1 deletion man/addImageQuery.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/imagequeryOptions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.