+ Reply to Thread
Results 1 to 2 of 2

Thread: Problem with Graphics Layer

  1. #1
    Nigel Alford
    Join Date
    Apr 2011
    Posts
    80
    Points
    1
    Answers Provided
    1


    0

    Default Problem with Graphics Layer

    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:
    Code:
    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:
    Code:
    <!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

  2. #2
    dan becker
    Join Date
    Apr 2010
    Posts
    182
    Points
    21
    Answers Provided
    3


    0

    Default Re: Problem with Graphics Layer

    In your locomotive query, you need to change the last line

    from:
    Code:
     MPQueryTask.execute(LocQuery, LocSymbology);
    to:
    Code:
    LocQueryTask.execute(LocQuery, LocSymbology);
    think you forgot to change it to the locomotive query task after you c/p it

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts