AnsweredAssumed Answered

view.hitTest bug with multipoint geometry?

Question asked by bflessner on Mar 28, 2017
Latest reply on Mar 30, 2017 by TSolow-esristaff

At 4.3, view.hitTest() method does not work on a esriGeometryMultipoint service. I set up a demo of the problem, but I couldn't find an ESRI sample service with multipoint geometry, so you'll have to supply your own. My test map service isn't public. Anyway, insert your multipoint geometry map service url and you will see that the cursor stays as the default when hovering over a multipoint feature but works correctly when hovering over a regular point. Or maybe I'm doing something wrong? Rene Rubalcava 

 

JS Bin - Collaborative JavaScript Debugging 

 

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <meta name="description" content="[Get started with MapView - Create a 2D map - 4.3]">
  <!--
  ArcGIS API for JavaScript, https://js.arcgis.com
  For more information about the get-started-mapview sample, read the original sample description at developers.arcgis.com.
  https://developers.arcgis.com/javascript/latest/get-started-mapview/index.html
  -->

<title>Get started with MapView - Create a 2D map - 4.3</title>
  <style>
    html,
    body,
    #viewDiv
{
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>


  <link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
  <script src="https://js.arcgis.com/4.3/"></script>

  <script>
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/FeatureLayer",
      "dojo/domReady!"
    ], function(Map, MapView, FeatureLayer) {

      var map = new Map({
        basemap: "streets"
      });

      var view = new MapView({
        container: "viewDiv",
        map: map,
        center: [-84.511, 39.092],
           zoom: 15
      });
     
      var points = new FeatureLayer({
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/0"
      });
      map.add(points);
     
      //var multipoint = new FeatureLayer({
      //  url: "INSERT MULTIPOINT GEOMETRY SERVICE HERE /0"
      //});
      //map.add(multipoint);
     
      view.on('pointer-move', function(evt){
        view.hitTest({x: evt.x, y: evt.y}).then(changeCursor);
      });

      function changeCursor(response){
        if (response.results.length > 0){
          document.getElementById("viewDiv").style.cursor = "pointer";
        } else {
          document.getElementById("viewDiv").style.cursor = "default";
        }
      }

    });
  </script>

</head>

<body>
  <div id="viewDiv"></div>
</body>
</html>

Outcomes