Othelie

how to make graphics into graphicsLayer

Discussion created by Othelie on May 27, 2012
I managed to change it from graphics to graphicsLayer.
But next step.
Is there a way to show the attributes for all lines in gpResult in a popup window?
gpResult is a set of routes with attributes RouteName, FirstStop, LastStop, NumOfStops, Total_Time, and Total_Length.

function executeGP() {

    map.graphics.clear();

    var params = {};
    esri.show(loading);
    gp.submitJob(params, completeCallback, statusCallback, function (error) {
        alert(error);
        esri.hide(loading);

    });
}

function statusCallback(jobInfo) {
    console.log(jobInfo.jobStatus);
    var status = jobInfo.jobStatus;
    if (status === "esriJobFailed") {
        alert(status);
        esri.hide(loading);
    } else if (status === "esriJobSucceeded") {
        esri.hide(loading);
    }
}

function completeCallback(jobInfo) {
    console.log("getting data");
    gp.getResultData(jobInfo.jobId, "Routes", displayResult);
}


function displayResult(result, messages) {
    var simpleLineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 3);
    var features = result.value.features;
    var gpResult = new esri.layers.GraphicsLayer({
        id: "Result"
    });
    for (var f = 0, fl = features.length; f < fl; f++) {
        var feature = features[f];
        feature.setSymbol(simpleLineSymbol);
        gpResult.add(feature);

    }
    map.addLayer(gpResult);
}

Outcomes