AnsweredAssumed Answered

Graphic Layer array empty but showing geometry

Question asked by rralbritton on Jan 31, 2017
Latest reply on Jan 31, 2017 by rralbritton

I need to access the geometry properties of a graphics array so that I can update the associate attribute values, but when I try and view the properties of my graphics layer the Array is empty - but the graphics are shown on the map. 


I've tried changing the log statement to not anything until the graphics "load", "update" or 'update-end" but then it doesn't log anything. What happening here?


Note: The relevant code starts on line 42


    // Create the map
    var map = new Map("map", {
      basemap: "topo",
      center: [-111.841947, 40.765530],
      zoom: 15

    //Create Graphics Layer
    var stopsGraphicsLayer = new GraphicsLayer({
      id: "stopsGraphicsLayer"

       var vehicleLocationGraphicsLayer = new GraphicsLayer({
      id: "vehicleLocationGraphicsLayer"
    var basemap = new ArcGISTiledMapServiceLayer("");

    //add graphics layer

    //Create Toggles
    var vehicleInterval;

    var vehicle = new Switch({
      id: "vehicle", //defines css - and you can not repeat and id
      value: "off",
      "class": "mblSwSquareShape"
    vehicle.placeAt(document.body); // e.g add the switch to body

    vehicle.on("stateChanged", function(newstate) {
      if (newstate === "on") {
        //Request vehicle locations
        esriVehicleRequest(15).then(function(vehicleResponse) {
               //I've tried "update", 'update-end' as well with no success
               vehicleLocationGraphicsLayer.on("load", function(){
               //logs an empty array
               //console.log( vehicleLocationGraphicsLayer);
          vehicleInterval = setInterval(function(){
               //Make an esriRequest

                    //Update each graphic in the GL with data from the esriRequest
                    for (graphics = 0; graphics <; graphics++){
                         //update each graphic in the GL with data from the vehicleResponse
               }, 2000);
       else {
        //Stop setInterval
        //Clear graphics
        //Hide graphics layer

    function clearVehicleInterval(graphicsLayer) {

    function esriVehicleRequest(routeID) {
      return new esriRequest({
        url: "",
        content: {
          apikey: "ride1791",
          routeID: routeID
        handleAs: "json",
        callbackParamName: "method"
      }).then(function(data) {
        return data;

    function vehicleGraphicFunction(data) {
       var vehicleObjects = data      
       var vehicleGraphic;
       var vehicleAttributes;
          for (i=0; i < vehicleObjects.length; i++ ){
               //Create Symbology
               var vehiclePNG = new PictureMarkerSymbol({
                    url: "",
                    height: 30,
                    width: 30

                 //Create Graphic
                 vehicleGraphic = new Graphic(new Point(vehicleObjects[i].Longitude, vehicleObjects[i].Latitude, map.SpatialReference), vehiclePNG, vehicleObjects[i].VehicleID);
                 //add graphics to layer