AnsweredAssumed Answered

how to add mouse hover event to a polygon in javascript

Question asked by purnima.mtcg on Apr 13, 2017
Latest reply on Apr 18, 2017 by rscheitlin
hii,
thank u so much for replying me. now i can add polygon . but can not add any event to it.
kindly help me to add a mouse hover event to a particular polygon.
when i hover on a polygon its fill color should be changed. and show a popup.. i am copy-paste my code here.. u can check it and kindly help me..
my code....
 
<!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 graphics - 4.3]">
  <!--
  ArcGIS API for JavaScript, https://js.arcgis.com
  For more information about the get-started-graphics sample, read the original sample description at developers.arcgis.com.
  -->
<title>Get started with graphics - 4.3</title>
 
  <link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
  <script src="https://js.arcgis.com/4.3/"></script>
 
  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>
 
  <script>
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/Graphic",
      "esri/geometry/Point",
      "esri/geometry/Polyline",
      "esri/geometry/Polygon",
      "esri/symbols/SimpleMarkerSymbol",
      "esri/symbols/SimpleLineSymbol",
      "esri/symbols/SimpleFillSymbol",
      "dojo/domReady!"
    ], function(
      Map, MapView,
      Graphic, Point, Polyline, Polygon,
      SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol
    ) {
 
      var map = new Map({
        basemap: "hybrid"
      });
 
      var view = new MapView({
        center: [-80, 35],
        container: "viewDiv",
        map: map,
        zoom: 3
      });
 
 
      /************************
       * Create a polygon graphic
       ************************/
 
      // Create a polygon geometry
      var polygon = new Polygon({
        rings: [
          [-64.78, 32.3],
          [-66.07, 18.45],
          [-80.21, 25.78],[-92.21, 35.78],[-85.21, 32.78],
          [-64.78, 32.3]
        ]
      });
 
      // Create a symbol for rendering the graphic
      var fillSymbol = new SimpleFillSymbol({
        color: [227, 139, 79, 0.8],
        outline: { // autocasts as new SimpleLineSymbol()
          color: [255, 255, 255],
          width: 1
        }
      });
 
      // Add the geometry and symbol to a new graphic
      var polygonGraphic = new Graphic({
        geometry: polygon,
        symbol: fillSymbol
      });
 
      // Add the graphics to the view's graphics layer
      view.graphics.addMany([polygonGraphic]);
    });
  </script>
</head>
 
<body>
  <div id="viewDiv"></div>
</body>
 
</html>
thank u

Outcomes