Resizing and scalebar to a Query Map

Discussion created by code_newbie on Oct 10, 2011
Latest reply on Oct 16, 2011 by DSwingley-esristaff
Hi all,
     am new and I am having some difficulty displaying a scale bare when I use a query map. I cannot seem to figure out how to add a scalebar and insure my maps resize.  Here is my code:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
<!--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, results as an InfoWindow</title>
<link rel="stylesheet" type="text/css" href="">
<style type="text/css">
      html, body {height: 100%; width: 100%; margin: 1; padding: 0;}
      body{background-color:#730; overflow:hidden; font-family: "Trebuchet MS"; border:5px solid black} 
      #map{overflow:hidden; padding:0;}
   .AppTitle{font-size:3em; color: yellow;}
   .esriScalebar{height: 60%;}

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





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

    function init() {
        var initialExtent = new esri.geometry.Extent({"xmin":-120.227821999585,"ymin":20.5332698820995,"xmax":-65.9816769016675,"ymax":71.4062353670687,"spatialReference":{"wkid":4326}});
        map = new esri.Map("mapDiv", {
          extent: initialExtent

//create and add new layer
var layer = new esri.layers.ArcGISDynamicMapServiceLayer("");

//Listen for click event on the map, when the user clicks on the map call executeQueryTask function.
dojo.connect(map, "onClick", executeQueryTask);

//build query task
queryTask = new esri.tasks.QueryTask("");

//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.returnGeometry = true;
query.outFields = ["STATE_NAME", "STATE_ABBR", "SQMI", "MALES", "FEMALES"];

//create the infoTemplate to be used in the infoWindow.
//All ${attributeName} will be substituted with the attribute value for current feature.
infoTemplate = new esri.InfoTemplate("${STATE_NAME}", "Abbreviation: ${STATE_ABBR}<br />Square Miles: ${SQMI}<br /> # of Males: ${MALES}<br /> # of Females: ${FEMALES}");

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]));


function executeQueryTask(evt) {
//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, showResults);

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

var features = featureSet.features;

//QueryTask returns a featureSet. Loop through features in the featureSet and add them to the map.
var graphic = feature;

//Set the infoTemplate.

//Add graphic to the map graphics layer.;


dojo.connect(, "onMouseMove", function(evt) {
var g = evt.graphic;
dojo.connect(, "onMouseOut", function() {map.infoWindow.hide();} );


<body class="claro">
Click on a state to get more info. When state is highlighted, move mouse over state to get more info.
<div id="mapDiv" style="width:600px; height:600px; border:1px solid #000;"></div>

  <body class="claro">
    <div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false"
    style="width: 100%; height: 100%;">
      <div id="map" dojotype="dijit.layout.ContentPane" region="center">
   <div dojotype="dijit.layout.ContentPane" region="top" style="width: 100%; height: 20%;">
   <div style="position: absolute; top: 60px; left:900px;"> <span class="AppTitle"> Newbie Test</span> </div>