Imitate right click "What's Here?" from map viewer

208
1
Jump to solution
02-22-2024 10:57 AM
DavinShokes1
Occasional Contributor II

The AGOL map viewer allows you to right click, see a context menu with "What's Here", reverse geocode the location, and display results in the popup.

whatshere.gif

 

 

 

How do you mimic this with the javascript api 4.28?

I believe the event click and the reverse-geocode docs should get most of the way. I'm not sure about the context menu. The closest thing for 4.x I could find is the ButtonMenuViewModel. There are no samples available for usage.

There is also a sample from 3.x that does similar functionality. 

 https://developers.arcgis.com/javascript/3/jssamples/graphics_contextmenu.html 

Thank you!

 

0 Kudos
1 Solution

Accepted Solutions
LaurenBoyd
Esri Contributor

Hi @DavinShokes1 - 

Here's an example on how this could be implemented with a button in the view (based off the Intro to popups sample ) :https://codepen.io/laurenb14/pen/QWoRRpj?editors=1000

The workflow goes something like this:

  1. Watch when the MapView click event occurs.
  2. Check if the right button was clicked and add a graphic to the map where the user clicked.
  3. Display a button or tooltip to open the popup with the information from the reverse geocoding using the MapView.openPopup() method.

You can always implement some sort of clickable tooltip to display at the clicked location as well.

Hope this helps!

Lauren

View solution in original post

1 Reply
LaurenBoyd
Esri Contributor

Hi @DavinShokes1 - 

Here's an example on how this could be implemented with a button in the view (based off the Intro to popups sample ) :https://codepen.io/laurenb14/pen/QWoRRpj?editors=1000

The workflow goes something like this:

  1. Watch when the MapView click event occurs.
  2. Check if the right button was clicked and add a graphic to the map where the user clicked.
  3. Display a button or tooltip to open the popup with the information from the reverse geocoding using the MapView.openPopup() method.

You can always implement some sort of clickable tooltip to display at the clicked location as well.

Hope this helps!

Lauren