Select to view content in your preferred language

Adding coordinates to popup / popupTemplate

3142
11
Jump to solution
10-04-2017 05:11 AM
PaulLohr
Regular Contributor

Working with the 3.22 JS API. Would someone please help me find sample code that adds coordinates ( latitude / longitude ) to a popup when popupTemplate is in use. There are plenty of popup and infoWindow samples which do not use popupTemplate but rather simply call the setContent method.

For the current time I am sticking with popup / popupTemplate rather than infoWindow because the former seems to handle things such as charts, attachments and relationships while I'm not sure that infoWindow handles any of these (feel free to correct me). I am open to changing my approach.

It seems that popup / popupTemplate are called upon map load which makes it tricky to get the coordinates of a click event that occurs well after the map has loaded.

Thank you for any help,

Paul Lohr

0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus

Paul,

   I see my error in the code. The reason you are getting an array of all elements in the popup node is that the query was malformed.

What I had before was:

var node = dojo.query("[dojoattachpoint]=\"_description\"", map.infoWindow.domNode)[1];

which was returning all the nodes of the map.infoWindow.dom, because there was not a valid query to execute, and thus the need to specify the 2 node in the returned array with [1].

var node = dojo.query("[dojoattachpoint=\"_description\"]", map.infoWindow.domNode)[0];

In this proper query string the right square bracket is in the proper location and the use of the [0] means give me the first and only element in the array.

As far as you trying to add the lat and lon to the gallery div the reason it is not showing is the fact that the gallery div is a child of the mediaSection div which is hidden (it has this class: mediaSection hidden).

PaulLohr
Regular Contributor

Thank you for point this out, Robert. 

0 Kudos