Preventing centering of map using GoTo in 4.2

1209
2
Jump to solution
12-29-2016 05:25 PM
LoriEmerson_McCormack
Occasional Contributor

I am using the GoTo in the 4.2 JavaScript API in combination with the Sample Code that queries a feature, creates a list, and then opens the Popup when clicking on one of the list items.  The problem is that when I click on a LINE feature at the top of my map, the popup displays off my page (the Popup always displays above the Line feature).  However, if I click the same map feature (not the list), then the map scoots down to display the Popup correctly.

How can I get the map to scoot down when using the GoTo command in the 4.x JavaScript API? Or, how do I get the Popup to display below the line so that it fits within the map view?

//*********************************************

// Listen to click event on the road name list

//*********************************************

on(listNode, on.selector("li", a11yclick), function (evt) {

var target = evt.target;

var resultId = domAttr.get(target, "data-result-id");

//** if zoomed in, go back to the initial extent

view.goTo({

zoom: myViewZoom,

center: myViewCenter,

});

// get the graphic corresponding to the clicked ADT entry

var result = resultId && graphics && graphics[parseInt(resultId, 10)];

if (result) {

// open the popup at the ADT polyline

// and set the popup's features which will populate popup content and title.

var mid_res = Math.round(result.geometry.paths[0].length / 2);

result.geometry.x = result.geometry.paths[0][mid_res][0];

result.geometry.y = result.geometry.paths[0][mid_res][1];

view.popup.open({

features: [result],

location: result.geometry

});

}

});

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lori,

   Sounds like you need to call popup.repostion():

reposition:

Positions the popup on the view. Moves the popup into the view's extent if the popup is partially or fully outside the view's extent.

If the popup is partially out of view, the view will move to fully show the popup. If the popup is fully out of view, the view will move to the popup's location.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Lori,

   Sounds like you need to call popup.repostion():

reposition:

Positions the popup on the view. Moves the popup into the view's extent if the popup is partially or fully outside the view's extent.

If the popup is partially out of view, the view will move to fully show the popup. If the popup is fully out of view, the view will move to the popup's location.

LoriEmerson_McCormack
Occasional Contributor

Robert,

Thanks for your response.  You have answered other questions I have had on this forum, and I greatly appreciate it.

I was able to get the view.popup.reposition(); to work once I removed the view.goTo code.

0 Kudos