Trying to get InfoWindow sample to work

Discussion created by sjkidd on Mar 24, 2011
Latest reply on Mar 25, 2011 by sjkidd
Hello all - I hope someone can take a moment to help me out. All I want to do is click on my points and show an InfoWindow. I used this example

I replaced the layers with my own and can see my points on top of the background layer. I also altered the fields in the query. When I click on the points, nothing happens. Here is my code:




    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <meta http-equiv="X-UA-Compatible" content="IE=7" />

    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 

      on iOS devices-->

    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>

    <title>QueryTask with geometry, queries with multiple results at the same location are displayed in an InfoWindow</title>

    <link rel="stylesheet" type="text/css" href="">

    <script type="text/javascript" src=""></script>

    <script type="text/javascript" language="Javascript">



      var map, queryTask, query;

      var featureSet;

      function init() {

        var startExtent = new esri.geometry.Extent({"xmin":-8625438.488209609,"ymin":4369606.075512551,"xmax":-8441989.620325275,"ymax":4553054.943396885,"spatialReference":{"wkid":102100}});

        //create map

        map = new esri.Map("mapDiv", {extent: startExtent});

        var tiledLayer = new esri.layers.ArcGISTiledMapServiceLayer("");

         //Add housing portal sites
        var dynamicLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost/ArcGIS/rest/services/IntranetServices/Portal_SP/MapServer");

        //Listen for click event on the map, when the user clicks on the map call executeQueryTask function.

        dojo.connect(map, "onClick", executeQueryTask);

        //Listent for infoWindow onHide event

        dojo.connect(map.infoWindow, "onHide", function() {;});

        //build query task

        queryTask = new esri.tasks.QueryTask("http://localhost/ArcGIS/rest/services/IntranetServices/Portal_SP/MapServer/0");

        //Can listen for onComplete event to process results or can use the callback option in the queryTask.execute method.

        //dojo.connect(queryTask, "onComplete", showResults);

        //build query filter

        query = new esri.tasks.Query();

        query.outSpatialReference = {"wkid":102100};

        query.returnGeometry = true;

        query.outFields = ["Organizati", "ProgramTyp"];
      function executeQueryTask(evt) {


        featureSet = null;

        //onClick event returns the evt point where the user clicked on the map.

        //This is contains the mapPoint (esri.geometry.point) and the screenPoint (pixel xy where the user clicked).

        //set query geometry = to evt.mapPoint Geometry

        query.geometry = evt.mapPoint;

        //Execute task and call showResults on completion

        queryTask.execute(query, function(fset) {

          if (fset.features.length === 1) {


          } else if (fset.features.length !== 0) {






      function showFeature(feature,evt) {;

        //set symbol

        //var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.5]));


        //construct infowindow title and content

        var attr = feature.attributes;

        var title = attr.FIELD_NAME;

        var content = "Organization : " + attr.Organizati

                    + "<br />Program Type : " + attr.ProgramTyp;;



        (evt) ?,map.getInfoWindowAnchor(evt.screenPoint)) : null;


      function showFeatureSet(fset,evt) {

        //remove all graphics on the maps graphics layer;

        var screenPoint = evt.screenPoint;

        featureSet = fset;

        var numFeatures = featureSet.features.length;

        //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the infowindow.

        var title = "You have selected " + numFeatures + " fields.";

        var content = "Please select desired field from the list below.<br />";

        for (var i=0; i<numFeatures; i++) {

          var graphic = featureSet.features[i];

          content = content + graphic.attributes.FIELD_NAME + " Field (<A href='#' onclick='showFeature(featureSet.features[" + i + "]);'>show</A>)<br/>";








  <body class="claro">

    Housing Portal Sample 

    <div id="mapDiv" style="width:800px; height:600px; border:1px solid #000;"></div>



I'm obviously new to this but I can't figure out how only swapping out the data layers in the sample results in it not working. Does it have something to do with different geometry types? I commented out the code about the symbol since I have points, not polygons.