Feature Widget

Loading...

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample displays information based on the PopupTemplate using the Feature widget. You can use this widget to display information normally found in the Popup without having to use the Popup itself. You can also use this information in a custom widget or other parts of your application.

// Provide graphic to a new instance of a Feature widget
const feature = new Feature({
  graphic: graphic,
  view: view
});

view.ui.add(feature, "bottom-left");

// Listen for the pointer-move event on the View
view.on("pointer-move", function(event) {
  // Perform a hitTest on the View
  view.hitTest(event).then(function(hitTestResult) {
    const result = hitTestResult.results[0];
    highlight && highlight.remove();
    // Update the graphic of the Feature widget
    // on pointer-move with the result
    if (result) {
      feature.graphic = result.graphic;
      highlight = layerView.highlight(result.graphic);
    }
    else {
      feature.graphic = graphic;
    }
  });
});

Sample search results

TitleSample
Loading...