Query Task within Tooltip Dialog pop up window

Discussion created by camirvine on Jul 7, 2011

I am trying to use the dojo tooltip dialog widget which is in the samples on the ESRI Javascript page -  I want it to be added to any address pages on our website so that when a user clicks the hyperlink it parses a property reference to a querytask that zooms to the property and highlights it.

However, when I have tried to do this using the tool tip widget it doesn't work.  The map appears but it doesn't zoom to the location of the property.  I guess the question I have is can the map object be created on a dynamic div content?

This is what we have tried:

When the map object is created on a div that is the content on a dojo tooltip that is created in the following steps:

1. Create the dojo tooltip as:

     var htmlFragment = '<div>Click on the map.</div>';
          htmlFragment += '<div id="mapTwo" style="width:350px; height:350px; border: 1px solid #A8A8A8;"></div>';
          tooltipDialog = new dijit.TooltipDialog({
            content: htmlFragment,
            autofocus: !dojo.isIE, // NOTE: turning focus ON in IE causes errors when reopening the dialog
            refocus: !dojo.isIE

2. Create the map object as:

var map = new esri.Map("mapDiv" ,{
          slider: false

3. Execute a Query as:
  create the query task and set the query parameters with the where clause.
        queryTask.execute(query, function(fset){
   if (fset.features.length === 1) {    

4. Show features will zoom to the extent

function showFeature(feature) {;
        curFeature = feature;
           var fExtent = feature.geometry.getExtent();
        var centerPt = fExtent.getCenter();
      var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 255, 0]), 5), new dojo.Color([0, 0, 0, 0.25])); 
           feature.setInfoTemplate(new esri.InfoTemplate ("Address", "${FullAddressNoAddr1}" ));  
           map.infoWindow.resize(150, 100);  
 , map.getInfoWindowAnchor(map.toScreen(centerPt)));

Basically this does not work and the zoomed map is not shown. But debug messages show that the query is executed and the results are fetched in the show features.

But if the change is made such that the map object is created on a div that is created in the body of the html tag as:
<div id="mapDiv" style="width:450px; height:350px; border: 1px solid #A8A8A8;"></div>

And the init function is called on load

The init function created the map as:
map = new esri.Map("mapDiv", {
   nav: true,
   displayGraphicsOnPan: !dojo.isIE

This works and the map is displayed to the zoomed in location.

I hope what we are trying to achieve is clear.