Select to view content in your preferred language

Simple custom URL widget, based on clicked location on map

912
3
02-24-2022 11:51 AM
JohnSasso2
Frequent Contributor

Hi @RobertScheitlin__GISP I have a request, which I hope is simple, or perhaps you can lead me in the right direction.

I want to create a simple widget where, if I click anywhere on my map, it shows either in a pop-op box or other small, separate window a URL dynamically-created based on the lat-long coordinates.  To clarify, here's an example:

I go to this widget click on the pin icon (similar to what's in the Measurement widget).  I then click anyplace on the map, and lets suppose the point I am at is 42.7192992,-73.8323004.  What happens when I click is that a URL for a specific website appears with the location, e.g., if URL = https://www.google.com/maps/ then I'd get:

https://www.google.com/maps/@42.7192992,-73.8323004,18z

which I can then click on to bring me to a Google Maps window.  I'm trying to wrangle this out in TypeScript, albeit with very limited experience with the language.   Thanks!

 

0 Kudos
3 Replies
LefterisKoumis
Frequent Contributor

This sounds very similar to the workflow that I used on my custom widget in WAB.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

@JohnSasso2 

Have you seen this sample?

https://developers.arcgis.com/experience-builder/sample-code/widgets/get-map-coordinates-function/

You can also look at the code in custom widgets like my elocate to get coding examples (specifically the widget.tsx handleRevGeocodeBtnClick function).

0 Kudos
JohnSasso2
Frequent Contributor

Yes, I have.  What I am trying to do is sort of reverse-engineer the Meaurement widget, pruning out some things and trying to add what I need

0 Kudos