0

Is there a way to change the case of a text field in an InfoTemplate using ArcGIS JavaScript 3.3?

Let's say I am bringing in a feature layer, and it is a requirement that I ensure that the field value for {$gaugelid} is lowercase, as I am constructing a URL to preview that particular Gauge ID's Hydro-graph in the Info template.

The formatting for the Hydro-Graph URL is: https://water.weather.gov/resources/hydrographs/Lowercase(${gaugelid})_hg.png)

If it's not possible when constructing the InfoTemplate, is there a way to define that I want those values as lowercase in the definitionExpression or when I define the outFields?

var HydroURL = 'https://water.weather.gov/resources/hydrographs/${gaugelid}_hg.png';
var iframeHydro = "<iframe src='"+HydroURL+"' style='width:100%;height = '400';'></iframe>";
console.log(iframeHydro);
var content = "<b>Location: </b>${location}<br><a href='${url}'><b>Status: </b>${status}</a><br><b>Observation:</b>${observed}${units}<br><b>Observation Time: </b>${obstime}<br>"+iframeHydro;
var gaugetemplate = new InfoTemplate("${gaugelid}", content);

var currentGaugeData_lyr = new FeatureLayer(
    "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Observations/ahps_riv_gauges/MapServer/0",
    {
      definitionExpression: "state = 'TX'",
      outFields: ["*"],
      infoTemplate: gaugetemplate
    }
  );
var gaugeSymbol = new SimpleMarkerSymbol();
1

There is no way to ask for the data to be returned lowercase, but you can display it lowercase once you have the data on the client.

There is a sample that shows how to use custom functions, and a help page that talks more about this:

https://developers.arcgis.com/javascript/3/jssamples/widget_formatInfoWindow.html https://developers.arcgis.com/javascript/3/jshelp/intro_formatinfowindow.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.