Home widget / Default Extent when querying by URL params

444
1
02-18-2021 08:29 AM
luckachi
Occasional Contributor III

I have a map that queries data based on URL parameters and zooms to the extent of the features (queryExtent). I'd like to add the home widget so that when users zoom in to specific points, they can click on the button to return to the initial extent. Right now, when I click on the standard home widget, spins and spins.

var homeButton = new Home({
          view: view,
        });

        // adds the home widget to the top left corner of the MapView
        view.ui.add(homeButton, "top-left");

I gather I need to somehow connect the home widget to the query but I am not quite sure how to go about it (if that is in fact what needs to occur). 

0 Kudos
1 Reply
AnthonyTimpson1
New Contributor

Hello, 

looks like you need to define a viewpoint for the home button to return to. 

you can likely use the extent it initially zooms to with queryExtent to define a viewpoint.

var homeButton = new Home({ view: view, viewpoint: new Viewpoint() });

 

 

0 Kudos