Problem with identify task

509
4
05-19-2010 06:14 AM
AndyBurns
Occasional Contributor
Hi All.

We seem to have hit a brick wall with our development, especially with the identify task!

When we set this up, we can see the task actually working when clicking on a map however we get no info window pop up. If we look at the response from the server, we can see it working all the way back to the users browser however no pop up with info. We have however tried to integrate it into our currentl development and not in a individual task.

So we currently have a index.html; referencing around 4-5css files and so far, wer have 5 js files, each file for a specific function. We have checked our code over and over and cannot see why it is failing. Any ideas or any code you would like to look at to see if we are going wrong?

We are running JS API v1.5 and 1.6.

thanks
0 Kudos
4 Replies
DerekSwingley
Occasional Contributor
Can you post the code for your callback function that is called by your identify task?
0 Kudos
AndyBurns
Occasional Contributor
Hi there. Please see code below:

function initFunctionality(map) {
    dojo.connect(map, "onClick", doIdentify);

    identifyTask = new esri.tasks.IdentifyTask("http://soya.maps.test.shropshire.gov.uk/ArcGIS/rest/services/LBSR/MapServer");

    identifyParams = new esri.tasks.IdentifyParameters();
    identifyParams.tolerance = 2;
    identifyParams.returnGeometry = true;
    identifyParams.layerIds = [5, 1, 2, 0, 7];
    identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;

    map.infoWindow.resize(515, 200);
    map.infoWindow.setContent(dijit.byId("tabs").domNode);
    map.infoWindow.setTitle("Identify Results");

    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 doIdentify(evt) {
    map.graphics.clear();
    identifyParams.geometry = evt.mapPoint;
    identifyParams.mapExtent = map.extent;
    identifyTask.execute(identifyParams, function(idResults) { addToMap(idResults, evt); });
}

function addToMap(idResults, evt) {
    layer5results = { displayFieldName: null, features: [] };
    layer0results = { displayFieldName: null, features: [] };
    layer1results = { displayFieldName: null, features: [] };
    layer2results = { displayFieldName: null, features: [] };
    layer7results = { displayFieldName: null, features: [] };



    for (var i = 0, il = idResults.length; i < il; i++) {
        var idResult = idResults;
        if (idResult.layerId === 5) {
            if (!layer5results.displayFieldName) { layer5results.displayFieldName = idResult.displayFieldName };
            layer5results.features.push(idResult.feature);
        } else if (idResult.layerId === 1) {
            if (!layer1results.displayFieldName) { layer1results.displayFieldName = idResult.displayFieldName };
            layer1results.features.push(idResult.feature);
        } else if (idResult.layerId === 2) {
            if (!layer2results.displayFieldName) { layer2results.displayFieldName = idResult.displayFieldName };
            layer2results.features.push(idResult.feature);
        } else if (idResult.layerId === 0) {
            if (!layer0results.displayFieldName) { layer0results.displayFieldName = idResult.displayFieldName };
            layer0results.features.push(idResult.feature);
        } else if (idResult.layerId === 7) {
            if (!layer7results.displayFieldName) { layer7results.displayFieldName = idResult.displayFieldName };
            layer7results.features.push(idResult.feature);
        }
    }
    dijit.byId("layer5Tab").setContent(layerTabContent(layer5results, "layer5results"));
    dijit.byId("layer1Tab").setContent(layerTabContent(layer1results, "layer1results"));
    dijit.byId("layer2Tab").setContent(layerTabContent(layer2results, "layer2results"));
    dijit.byId("layer0Tab").setContent(layerTabContent(layer0results, "layer0results"));
    dijit.byId("layer7Tab").setContent(layerTabContent(layer7results, "layer7results"));

    map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
}

function layerTabContent(layerResults, layerName) {
    var content = "";
    switch (layerName) {
        case "layer5results":
            content = "<i>Total features returned: " + layerResults.features.length + "</i>";
            content += "<table border='1'><tr><th>Street Name</th><th>Site Class</th><th>USRN</th></tr>";
            for (var i = 0, il = layerResults.features.length; i < il; i++) {
                content += "<td>" + layerResults.features.attributes['STREET_NAM'] + "</td>";
                content += "<td>" + layerResults.features.attributes['SITE_CLASS'] + "</td>";
                content += "<td>" + layerResults.features.attributes['USRN'] + " <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(Send to CRM)</a></td>";
            }
            content += "</tr></table>";
            break;
        case "layer1results":
            content = "<i>Total features returned: " + layerResults.features.length + "</i>";
            content += "<table border='1'><tr><th>Feature ID</th><th>Feature Label</th><th>Location</th><th>Site Name</th><th>Site Code</th></tr>";
            for (var i = 0, il = layerResults.features.length; i < il; i++) {
                content += "<tr><td>" + layerResults.features.attributes['ASSET_ID'] + "</td>";
                content += "<td>" + layerResults.features.attributes['FEAT_LABEL'] + "</td>";
                content += "<td>" + layerResults.features.attributes['LOCATION'] + "</td>";
                content += "<td>" + layerResults.features.attributes['SITE_NAME'] + "</td>";
                content += "<td>" + layerResults.features.attributes['SITE_CODE'] + " <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(Send to CRM)</a></td>";
            }
            content += "</tr></table>";
            break;
        case "layer2results":
            content = "<i>Total features returned: " + layerResults.features.length + "</i>";
            content += "<table border='1'><tr><th>Feature ID</th><th>Feature Label</th><th>Location</th><th>Site Name</th><th>Site Code</th></tr>";
            for (var i = 0, il = layerResults.features.length; i < il; i++) {
                content += "<td>" + layerResults.features.attributes['FEAT_ID'] + "</td>";
                content += "<td>" + layerResults.features.attributes['FEAT_LABEL'] + "</td>";
                content += "<td>" + layerResults.features.attributes['LOCATION'] + "</td>";
                content += "<td>" + layerResults.features.attributes['SITE_NAME'] + "</td>";
                content += "<td>" + layerResults.features.attributes['SITE_CODE'] + "<a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(Send to CRM)</a></td>";
            }
            content += "</tr></table>";
            break;
        case "layer0results":
            content = "<i>Total features returned: " + layerResults.features.length + "</i>";
            content += "<table border='1'><tr><th>Feature ID</th><th>Feature Label</th><th>Location</th><th>Site Name</th><th>Site Code</th></tr>";
            for (var i = 0, il = layerResults.features.length; i < il; i++) {
                content += "<tr><td>" + layerResults.features.attributes['FEATURE_ID'] + "</td>";
                content += "<td>" + layerResults.features.attributes['FEAT_LABEL'] + "</td>";
                content += "<td>" + layerResults.features.attributes['LOCATION'] + "</td>";
                content += "<td>" + layerResults.features.attributes['SITE_NAME'] + "</td>";
                content += "<td>" + layerResults.features.attributes['SITE_CODE'] + " <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(Send to CRM)</a></td>";
            }
            content += "</tr></table>";
            break;
        case "layer7results":
            content = "<i>Total features returned: " + layerResults.features.length + "</i>";
            content += "<table border='1'><tr><th>Area Name</th></tr>";
            for (var i = 0, il = layerResults.features.length; i < il; i++) {
                content += "<tr><td>" + layerResults.features.attributes['NAME'] + " <a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(Send to CRM)</a></td>";
            }
            content += "</tr></table>";
            break;
    }
    return content
}
0 Kudos
DerekSwingley
Occasional Contributor
Does addToMap() run? How about layerTabContent()? Use firebug and console.log statements or breakpoints to figure out where your code is stopping.
0 Kudos
AndyBurns
Occasional Contributor
Hi

thanks for the reply will investigate further.

regards
0 Kudos