Adding coordinates to InfoTemplate popup for ArcGIS Image Service Layer

1057
6
12-13-2017 09:40 AM
CenterlineMapping
New Contributor III

Hello,

Using Web AppBuilder and Javascript API 3.22, we are currently creating an InfoTemplate as below, and would like to know how to add map click coordinates (lat/lon) to the template as well.  Is this possible?  Would we need to create a this.map.onclick event, get coordinates from click, create a variable and place variable in the setContent function below?

var template = new InfoTemplate();
template.setTitle(" ");
template.setContent("${Raster.ItemPixelValue:NumberFormat}  <INSERT COORDINATES HERE>");

Thanks for your help and time!

Tags (1)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Here is a thread where I show how to add lat long to any popup:

https://community.esri.com/thread/205298-adding-xy-to-popup-in-wab-applicaiton 

CenterlineMapping
New Contributor III

Thank you for the link, Robert.

I'm not sure how that code would work using the InfoTemplate object and code as above.  I will continue to investigate.  Might need to use the InfoWindowBase Popup although we are applying this for an ArcGIS Image Service layer as shown below so not sure if this layer can use the Popup as an infoTemplate.

imageServiceLayer = new ArcGISImageServiceLayer("<ImageURL", {
        imageServiceParameters: params,
        infoTemplate: template,
        opacity: 0.8
        });

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

You are over thinking this. The code provided does not care what you are using it just adds the click coordinates to any popup that is shown.

0 Kudos
CenterlineMapping
New Contributor III

Robert, I should explain that we are adding layers to the web application map dynamically through JavaScript, rather than using layers loaded from a Web Map.  The Web Map we are loading has no layers within it, we are just using it for a basemap.  Once the Web Map loads and the user opens a Layer List widget, we add an Image Service to the web map via Javascript.  That is the reason I am creating an infotemplate and adding it to an imageServiceLayer.  We would like the user to click on the map/image service to retrieve pixel values and also view lat long for that click.  Thanks for your help!

 
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Again, Don't over think that you workflow will affect in any way the code I have provided. The fact that you are creating an InfoTemplate means that the Apps popup will be shown and my code will automatically add the click points coordinates to that popup.

RobertScheitlin__GISP
MVP Emeritus

Centerline Mapping,

   Did you ever try my code?