ngalford

Problem with Graphics Layer

Discussion created by ngalford on May 4, 2012
Latest reply on May 4, 2012 by dbecker88
I'm using the graphics layer example and one query works but the second doesn't and I'm stuck on the reason why. Both layers support Querying and the specified query works inside the service. I run a console log for both queries and I'm getting an error message:
ReferenceError
arguments: Array[1]
get message: function () { [native code] }
get stack: function () { [native code] }
set message: function () { [native code] }
set stack: function () { [native code] }
type: "not_defined"
__proto__: Error
 serverapi.arcgisonline.com:14
dojo.Deferred.reject.errback


Below is the code for the map:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Multiple Graphics Layers</title>
    <script type="text/javascript"  charset="utf-8" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.8compact"></script>
     <style type="text/css">
      html, body
      {
        height: 100%;
        margin: 0px;
        padding: 0px;
        width: 100%;
      }
            
       .esriSimpleSlider
       div
      {
        height: 30px !important;
        width: 30px !important;
      } 
      </style>
      
    <script type="text/javascript" charset="utf-8">
    
      dojo.require("esri.map");
      dojo.require("esri.virtualearth.VETiledLayer");
      dojo.require("esri.tasks.query");

      var map, BINGMAPS;

      function init() 
      {
        var supportsOrientationChange = "onorientationchange" in window,
          orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";

        window.addEventListener(orientationEvent, function () {
          orientationChanged();
        }, false);
        
        var initialExtent = new esri.geometry.Extent({ "xmin": -9414173.061, "ymin": 3995118.342, "xmax": -9398289.375, "ymax": 4014748.679, "spatialReference": { "wkid": 102100} });
        map = new esri.Map("map", {extent: initialExtent,wrapAround180: true, logo:false});
        
        dojo.connect(map, "onLoad", doQueries);
        veTileLayer = new esri.virtualearth.VETiledLayer({bingMapsKey: 'AimF6LphvVcbtQZOyiopeyQT8n-QOTukhwoRZwnzKL1MM0_B1Dfc7ppeKmyPByKp',
     mapStyle: esri.virtualearth.VETiledLayer.MAP_STYLE_ROAD});
  
     map.addLayer(veTileLayer);
      }

      function doQueries(map) 
      {
        //Milepost Query
        var MPQueryTask = new esri.tasks.QueryTask("http://esoc1.nscorp.com/ArcGISProduction/rest/services/EGIS/ENG_MPMARK/FeatureServer/0");
        var MPQuery = new esri.tasks.Query();
        MPQuery.outFields = [ "MPMARKER", "DIVCODE", "CREATEDATE", "ASSET_PK" ];     
        MPQuery.returnGeometry = true;
        MPQuery.where = "DIVCODE = '04'";
        //MPQuery.outSpatialReference = map.spatialReference;
        MPQueryTask.execute(MPQuery, MPSymbology);
        
        //Locomotive Query
        var LocQueryTask = new esri.tasks.QueryTask("http://esoc1.nscorp.com/ArcGISProduction/rest/services/ITGIS/LOCOMOTIVE_LOCATION/FeatureServer/0");
        var LocQuery = new esri.tasks.Query();
        LocQuery.outFields = ["*"]
        //[ "LOC_INIT", "LOC_NUM", "DTM", "FUEL_LEVEL", "ENGINE_ONOFF", "ENGINE_TEMP" ];     
        LocQuery.returnGeometry = true;
        LocQuery.where = "ENGINE_ONOFF = '1'";
        MPQueryTask.execute(LocQuery, LocSymbology);
        
      }       
     
     function MPSymbology(featureSet) 
     {
        var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE);
        symbol.setColor(new dojo.Color([0,0,255]), 1);
        var cityLayer = new esri.layers.GraphicsLayer();
        cityLayer.setInfoTemplate(new esri.InfoTemplate("${MPMARKER}","${*}"));        
        map.addLayer(cityLayer);
        dojo.forEach(featureSet.features, function(feature) {cityLayer.add(feature.setSymbol(symbol));
        console.log("MP Query: ", featureSet);  
        });
      } 
   function LocSymbology(featureSet) 
      {
        var Locsymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE);
        symbol.setColor(new dojo.Color([0,205,0]), 1);
        var LocLayer = new esri.layers.GraphicsLayer();
        LocLayer.setInfoTemplate(new esri.InfoTemplate("${LOC_INIT}","${*}"));        
        map.addLayer(LocLayer);
        dojo.forEach(featureSet.features, function(feature) {LocLayer.add(feature.setSymbol(Locsymbol));
        console.log("Loc Query: ", featureSet);  
        });
      }
      dojo.addOnLoad(init);
    </script>

  </head>
  <body>
    <div id="map" style="width:100%; height:100%;"></div>
  </body>
</html>


Thanks

Outcomes