Use ui.add to add multiple components to different view positions

949
2
Jump to solution
04-18-2019 06:05 AM
RL1
by
New Contributor II

I could not use the way it shows here to add multiple components to different positions, only the first component gets added. Am I missing something? I am using API 4.11. 

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add

mapView.ui.add(
{
component: home,
position: "bottom-right",
index: 0
}, {
component: zoom,
position: "bottom-right",
index: 1
}, {
component: searchWidget,
position: "top-right"
}, {
component: scaleBar,
position: "bottom-left"
});

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Your forgot the square brackets. The object has to be in an array.

mapView.ui.add([{
  component: home,
  position: "bottom-right",
  index: 0
}, {
  component: zoom,
  position: "bottom-right",
  index: 1
}, {
  component: searchWidget,
  position: "top-right"
}, {
  component: scaleBar,
  position: "bottom-left"
}]);

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Your forgot the square brackets. The object has to be in an array.

mapView.ui.add([{
  component: home,
  position: "bottom-right",
  index: 0
}, {
  component: zoom,
  position: "bottom-right",
  index: 1
}, {
  component: searchWidget,
  position: "top-right"
}, {
  component: scaleBar,
  position: "bottom-left"
}]);
0 Kudos
RL1
by
New Contributor II

OMG.. how did I miss that! Thanks, Robert!

0 Kudos