0

返された JSON オブジェクトをループして、x 座標と y 座標に基づいてヒートマップをプロットしようとしています。ヒートマップを設定する方法は次のとおりです。

function getHeatMap() {
heatLayer = new HeatmapLayer({
    config: {
        "useLocalMaximum": true,
        "radius": 40,
        "gradient": {
            0.45: "rgb(000,000,255)",
            0.55: "rgb(000,255,255)",
            0.65: "rgb(000,255,000)",
            0.95: "rgb(255,255,000)",
            1.00: "rgb(255,000,000)"
        }
    },
    "map": map,
    "domNodeId": "heatLayer",
    "opacity": 0.85
});

$.ajax({
    url: "index.aspx/getBusCommuter",
    type: "POST",
    data: "",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
        var parsed = JSON.parse(data.d);
        var data = [];
        $.each(parsed, function (i, jsondata) {
            var coordXicon = jsondata.BusStopX;
            var coordYicon = jsondata.BusStopY;

            data = [
                {
                    attributes: {},
                    geometry: {
                        spatialReference: { wkid: 102100 },
                        type: "point",
                        x: coordXicon,
                        y: coordYicon
                    }
                }
           ];
        });
        heatLayer.setData(data);
        map.addLayer(heatLayer);
    },
    error: function (request, state, errors) {
    }
});

}

基本的に、JSON オブジェクトは JSON オブジェクトの最後のセットにループし、すべてではなく最後のセットのみをプロットします。私の論理のどの部分が間違っていたのだろうか。

前もって感謝します。

4

1 に答える 1