Layer Activation with button/icon

Discussion created by Toton6868 on Feb 19, 2012
Latest reply on Feb 20, 2012 by bundarrabandito
I am new at JS API. I am trying to learn and apply this API. I want to display a point feature that will activate with click on button or icon or any link. I saw a sample with button click in ArcGIS Google API extension that is called query a point layer. I am giving the code here. I just want the same thing but not with Google.

<html debug=true>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Query Task (Returns Point)</title>

    <script src=";v=2&amp;key=DioG219lPJG3WTn3zmQqebsjVg" type="text/javascript"></script>
    <script src="" type="text/javascript" ></script>

    <script type="text/javascript">

      var gmap = null;
      var qtask = null;
      var query = null;
      var mapExtension = null;
      var gOverlays = null;

      function initialize() {
        // GMap construction
        gmap = new GMap2(document.getElementById('gmap'));
        gmap.addControl(new GLargeMapControl());
        gmap.addControl(new GMapTypeControl());
        gmap.setCenter(new GLatLng(33.96964806519751, -117.37674951553345), 17); // RIVERSIDE (Point)

        //Create MapExtension utility class
        mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);

        // Query Task
        qtask = new esri.arcgis.gmaps.QueryTask("");

        // You can execute a task and listen for the complete event or use the callback to get the results
        GEvent.addListener(qtask, "executecomplete", function() {
          //console.debug("'query task complete' event fired!!!");

        // Query
        query = new esri.arcgis.gmaps.Query();

      function executeQuery() {
        var bounds = gmap.getBounds();

        // clear map overlays and event listeners using MapExtension removeFromMap

        // set query parameters
        query.queryGeometry = bounds;
        query.returnGeometry = true;

        // execute query task
        qtask.execute(query, false, mycallback);


      function mycallback(fset) {
        // add the feature set to google map without any style
        gOverlays = mapExtension.addToMap(fset);



  <body onload="initialize();" onunload="GUnload();">
  <table width="100%" height="100%">
      <td align="center">

          <tr align="left">
              <input type="button" value="Execute Query" onclick="executeQuery();" /> 

              <input type="button" value="Clear Map Overlays" onclick="mapExtension.removeFromMap(gOverlays);" />

          <tr align="left" valign="top">
              <div id="gmap" style="width: 500px; height:500px;"></div>



What I have to do if I do the same thing in ArcGIS Javascript API???

Azizul Alam Toton
Asst. GIS Specialist
Data Expert (Pvt.) Ltd