AnsweredAssumed Answered

4.x: hitTest firing both callback and errback

Question asked by ellatrue on Apr 13, 2017
Latest reply on Apr 26, 2017 by ellatrue

I'm trying to use the HitTest() method to have one kind of popup whenever the user clicks on a feature, and another kind of popup when they click anywhere else on the map. However, the HitTest method seems to be firing both the callback AND the errback methods when I click on a feature, so it is showing the non-feature popup every time I click on a feature. How do I get it to do something only when the hit test fails?


I tested something similar in js bin, and it's doing the same thing when I use the popup function I'm trying to use, but not when I just had it print to the console for the errback instead. So maybe the problem is my AddPointGraphic function somehow. Am I using this wrongly somehow?,output

Just the view:


//Why is it firing both the callback and errback?
var screenPoint = {
   x: event.x,
   y: event.y
   function (response) {


function AddPointGraphic(event) {
   //clear previous graphics;

   //create new graphic
   var pointGeometry = event.mapPoint;

   var commentPointAtt = {
      long: event.mapPoint.longitude,
      lat: event.mapPoint.latitude

   var commentPoint = new Graphic({
      geometry: pointGeometry,
      symbol: symbol,
      attributes: commentPointAtt,
      popupTemplate: commentPopupTemplate
      features: [commentPoint],
      location: event.mapPoint

I tried using it in the hitTest(screenPoint).then(callback, errback) errback spot, but it did the same thing. I am new to 4.x and would appreciate any help.