problem with query task

Discussion created by ebanaka on Nov 10, 2010
Latest reply on Dec 17, 2010 by hzhu
Hi all!

I´m trying to make a web aplication with JavaScript API. there is a dynamic map service in my Arcgis server, it  I need for my work. I want to query one layer of map service.
By click on map should be displayed the results (infomation about point object) in Infowindow and should result a geometry on the map. I see the map, if I execute it in browser. but by click on point symbol it shows no Infowindow and no geometry on the map.
i think, it´s a swall problem, but I can´t find , where the problem is.


my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>QueryTask with value, results as an InfoWindow</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script>
    <script type="text/javascript" language="Javascript">

      var map, queryTask, query;
      var symbol, infoTemplate;

      function init() {
        //create map
       var startExtent = new esri.geometry.Extent({
          "xmin": 3479611.19575,
          "ymin": 5372668.28135,
          "xmax": 3572397.21575,
          "ymax": 5441668.28135,
          "spatialReference": {
          "wkid": 31493       }

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

        //create and add new layer
        var layer = new esri.layers.ArcGISDynamicMapServiceLayer("..../ArcGIS/rest/services/dienste/karte1/MapServer");

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

        //build query task
        queryTask = new esri.tasks.QueryTask("...../ArcGIS/rest/services/dienste/karte1/MapServer/0");

        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = true;
        query.outFields = ["OBJECTID","ObjTyp","Name","Strasse","PLZ","Ort"];

        //create the infoTemplate to be used in an InfoWindow.
        //All ${attributeName} will be substituted with the attribute value for current feature.
        infoTemplate = new esri.InfoTemplate("${OBJECTID}", "ObjektID : ${OBJECTID}<br/>Objekttype : ${ObjTyp}<br/> Name : ${Name}<br/>Strasse: ${Strasse}<br/>PLZ: ${PLZ}<br/>Ort: ${Ort}");

  //create symbol for selected features
  symbol = new esri.symbol.SimpleMarkerSymbol();
  symbol.setColor(new dojo.Color([255,255,0,0.5]));


   function executeQueryTask(evt) {
        //set query based on what user typed in for population;
         query.geometry = evt.mapPoint;

        //execute query and call showResults on completion

      function showResults(featureSet) {
        //remove all graphics on the maps graphics layer

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

  //Performance enhancer - assign featureSet array to a single variable.
  var resultFeatures = featureSet.features;

        for (var i=0, il=resultFeatures.length; i<il; i++) {
          //Get the current feature from the featureSet.
          //Feature is a graphic
          var graphic = resultFeatures[i];

          //Set the infoTemplate.

          //Add graphic to the map graphics layer.


  <body class="tundra">

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