Go Back or Forward to Previous Extents

2919
10
08-24-2023 06:30 AM
Labels (2)
JeffreyThompson2
MVP Frequent Contributor

This is a general purpose back/forward button set to go in a map widget. This widget will track any time a map extent is changed by a source other than itself and provide navigation buttons to go back or forward one extent or to either end of the list. It uses the same css class as the standard ESRI map buttons to blend in with the other map buttons. The buttons and their tooltips will disable themselves appropriately based on how many extents have been recorded and what extent the user is viewing. 

JeffreyThompson2_0-1692884326376.png

 

GIS Developer
City of Arlington, Texas
10 Replies
JeffreyThompson2
MVP Frequent Contributor

To make this widget ignore horizontal only extent changes (like those triggered by a sidebar opening or closing), add the following line just before if (firstLoad.current) {.

 

// Check the extents against the new extent. Must check corners as comparing objects will always result in false.
let extentChanged = false
if (newExtent.xmax !== node.current.value.xmax || newExtent.ymax !== node.current.value.ymax || newExtent.xmin !== node.current.value.xmin || newExtent.ymin !== node.current.value.ymin) {
    //console.log('extent change')
    extentChanged = true
}

// If only x values are change or there are no extent changes, do not log an extent change. 
if ((newExtent.xmax !== node.current.value.xmax || newExtent.xmin !== node.current.value.xmin || !extentChanged) && newExtent.ymax === node.current.value.ymax && newExtent.ymin === node.current.value.ymin) {
   //console.log('only x changed or no change')
   fromButtons.current = true
}

 

Switch x's and y's to make it ignore a vertically opening sidebar.

GIS Developer
City of Arlington, Texas
shodge_fsu
Occasional Contributor

I think there might be an issue with the code to stop recording sidebar movements.  I get an error saying that extentChanged is not valid.  I don't see it referenced anywhere else in the file.

I just downloaded the widget with the above link.  Maybe there is a newer version?

Otherwise the widget works great.

JeffreyThompson2
MVP Frequent Contributor

I left off another if statement necessary for the sidebar ignoring logic. Edited the code block above.

GIS Developer
City of Arlington, Texas
shodge_fsu
Occasional Contributor

Perfect!  Thanks for the speedy fix!

0 Kudos
RachappaBellappa1
Emerging Contributor

Hi

If i add it to the Dev edition exp builder it works fine but if i host it in portal then add it to the app inside the portal's exp builder if throws failed to load error and also not able to select map from the properties. Any thoughts? I am using 1.12/13 Exp builder version

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

I'm not sure. I haven't tried hosting a widget on Enterprise. My first guess would be compatibility issues between your version of Enterprise and the version of the widget. 

https://developers.arcgis.com/experience-builder/guide/release-versions/

It is marked in manifest.json as Experience Builder version 1.11, so it might not be accepted by Enterprise versions before 11.2. It should be backwards compatible to 1.9 if you want to try changing that, but there is a key Javascript API method that may not be fully compatible with Enterprise 11.0. 

GIS Developer
City of Arlington, Texas
0 Kudos
PatWalker
New Contributor

Hello,

I have added your Go Back or Forward to previous extents widget to my ExpBldr site and it works great, this is really needed as my users have that functionality in WAB.  The widget works flawlessly on my local development box, but trying to download the .Zip file to port it over to an IIS server fails.  If i remove this widget, the export to .Zip works as expected.  I am using Exp Bldr V1.14 now and am wondering if this widget needs to be, or could be updated to the latest release in order to complete the download of the .Zip file.  Thank you for this great widget, hoping i can deploy this in my Apps.

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

Experience Builder 1.14 should have back/forward buttons built in to the Map Widget, so this widget really isn't necessary anymore.

I can't really explain why it's not working for you. I assume you are following the standard steps of unzipping the downloadable folder to your-extensions/widgets, adding the widget to your Experience, saving and then publishing and downloading.

GIS Developer
City of Arlington, Texas
0 Kudos
TrystanJasperson
New Contributor

Hi,
I'm new to using this forum, but wanted to confirm with you if it is alright to use this as a consultant building experience builder applications on a state's portal?

0 Kudos