AnsweredAssumed Answered

Preventing centering of map using GoTo in 4.2

Question asked by lorieme on Dec 29, 2016
Latest reply on Dec 30, 2016 by lorieme

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

});

}

});

 

Outcomes