AnsweredAssumed Answered

Strange behaviour between FeatureLayer 'click' event and Map.InfoWindow popup

Question asked by landsmike on Jan 15, 2016
Latest reply on Jan 17, 2016 by Girish.Yadav

I'd encounter a strange situation.

 

When I do a mouse click very very near to a feature graphic, the InfoWindow pops up, but the 'click' event is not fired.

 

I suppose the InfoWindow will not popup since the click is not really inside the graphic.

 

It happens in ArcGIS JS version 3.15.

 

Sample Code for testing:

 

HTML

<html>

  <body>

    <h3>ArcGIS Map Test</h3>

    <div id="mapDiv"></div>

    <div id="coord">[Coordinates]</div>

  </body>

</html>

 

CSS

body {

  background-color: #999;

  padding: 5px;

}

#coord {

  padding-top: 10px;

}

 

JavaScript

var BASEMAP_URL = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";

 

var FEATURE_URL = "http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Heritage_Trees_Portland/FeatureServer/0";

 

require(["esri/map", "dojo/domReady!", "dojo/on", "esri/geometry/webMercatorUtils", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/Color"],

  function(Map, Ready, on, webMercatorUtils) {

 

    var map = new Map("mapDiv", {

      // center: [114.11547731560663, 22.342798067078743],

      center: [-122.66025506265751, 45.500974827876064],

      zoom: 13,

      nav: false

    });

 

    var baseMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer(BASEMAP_URL);

    map.addLayer(baseMapServiceLayer);

 

    var featureLayer = new esri.layers.FeatureLayer(FEATURE_URL);

 

    var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10,

      new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,

        new esri.Color([0, 0, 0, 255]), 1),

      new esri.Color([0, 197, 255, 255]));

 

    featureLayer.setRenderer(new esri.renderer.SimpleRenderer(symbol));

 

    featureLayer.on('mouse-over', function() {

      map.setMapCursor('pointer');

    });

 

    featureLayer.on('mouse-out', function() {

      map.setMapCursor('default');

    });

 

    featureLayer.on('click', function() {

      alert('on-click');

    });

 

    var template = new esri.InfoTemplate();

 

    template.setTitle("Feature Info");

    featureLayer.setInfoTemplate(template);

 

    map.addLayer(featureLayer);

  });

Outcomes