Select to view content in your preferred language

Symbol could not display when turn on base map

850
3
08-26-2013 11:07 AM
LouPhan
Deactivated User
I create a layer and upload to my arcgisserver, it displays well. I can see and click the symbol when i make a query.
However, when i add the base map, the symbols of query's results could not display or click.
       
map = new esri.Map("mapDiv", {

          basemap: "hybrid",// have a base map. Remove this code to delete the base map.

          center: [-34.541, 32.843],
          zoom: 3
        });


When i try to use a layer from:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map...
Everything works fine.

I really don't know how to fix it. Here is information of my layer.

Drawing Info: 
Renderer: 
Simple Renderer: 
Symbol: 
Simple Fill Symbol:
Style: esriSFSSolid, Color: [Undefined]
Outline: 
Simple Line Symbol:
Style: esriSLSSolid, Color: [255, 255, 255, 255], Width: 1



Here is information of the sample:
Drawing Info: 
Renderer: 
Simple Renderer: 
Symbol: 
Simple Fill Symbol:
Style: esriSFSSolid, Color: [206, 205, 250, 255]
Outline: 
Simple Line Symbol:
Style: esriSLSSolid, Color: [110, 110, 110, 255], Width: 0.4




Here is my HTML code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>QueryTask with value, results as an InfoWindow</title>
   <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
   <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css" />
     <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.5"></script>
    <script type="text/javascript" language="Javascript">
      dojo.require("esri.map");
      dojo.require("esri.tasks.query");

      var map, queryTask, query;
      var symbol, infoTemplate;

      function init() {
        //create map
       map = new esri.Map("mapDiv", {
          basemap: "hybrid",
          center: [-34.541, 32.843],
          zoom: 3
        });


  

        //create and add new layer
      //var layer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://crytal1-pc/ArcGIS/rest/services/USA/MapServer");
       //map.addLayer(layer1);
    var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer");
       map.addLayer(layer);
    
 
       //build query task
       queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/2");
       //queryTask = new esri.tasks.QueryTask("http://crytal1-pc/ArcGIS/rest/services/USA/MapServer/2");
        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = true;
 query.outFields = ["STATE_NAME", "POP1990"];

        //create the infoTemplate to be used in an InfoWindow.
        //All ${attributeName} will be substituted with the attribute value for current feature.
        infoTemplate = new esri.InfoTemplate("Hello", "State : ${STATE_NAME}<br />Population :");

  //create symbol for selected features
//symbol = new esri.symbol.PictureMarkerSymbol('http://static.arcgis.com/images/Symbols/Basic/YellowStickpin.png', 24, 24);
/*symbol = new esri.symbol.PictureMarkerSymbol({
"angle": 0,
"xoffset": 0,
"yoffset": 12,
"type": "esriPMS",
"url": "http://static.arcgis.com/images/Symbols/Basic/YellowStickpin.png",
"contentType": "image/png",
"width": 24,
"height": 24
});*/

  symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NONE, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([123,123,234]), 100), new dojo.Color([123,123,234,0.6]));
      }

   function executeQueryTask(population) {
        //set query based on what user typed in for population;
  //query.where = "POP2000 > " + population;
        query.where = "POP1990 > " + population;
        //execute query and call showResults on completion
        queryTask.execute(query,showResults);
      }


      function showResults(featureSet) {
        //remove all graphics on the maps graphics layer
        map.graphics.clear();
  
        //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the map.

  //Performance enhancer - assign featureSet array to a single variable.
  var resultFeatures = featureSet.features;

        for (var i=0, il=resultFeatures.length; i<il; i++) {
          //Get the current feature from the featureSet.
          //Feature is a graphic
          var graphic = resultFeatures;
          graphic.setSymbol(symbol);

          //Set the infoTemplate.
          graphic.setInfoTemplate(infoTemplate);

          //Add graphic to the map graphics layer.
          map.graphics.add(graphic);
        }
  var s = "";
        for (var i=0, il=featureSet.features.length; i<il; i++) {
          var featureAttributes = featureSet.features.attributes;
          for (att in featureAttributes) {
            s = s + "<b>" + att + ":</b>  " + featureAttributes[att] + "<br />";
          }
        }
        dojo.byId("info").innerHTML = s;
  
  
      }

      dojo.addOnLoad(init);
    </script>
  </head>
  <body class="claro">
  <br/>
      US city population greater than : <input type="text" id="population" value="500000" />
    <input type="button" value="Get Details" onclick="executeQueryTask(dojo.byId('population').value);" />


    <div id="mapDiv" style="width:600px; height:600px; border:1px solid #000;"></div>
 Click on a city once it's highlighted to get an InfoWindow.
 <div id="info"></div>
  </body>
</html>
0 Kudos
3 Replies
JasonZou
Frequent Contributor
Change esri.symbol.SimpleFillSymbol.STYLE_NONE to esri.symbol.SimpleFillSymbol.STYLE_NULL
0 Kudos
LouPhan
Deactivated User
I changed it but it could not work. Do I have change something in my layer?
Please help me. Thank you.
0 Kudos
JasonZou
Frequent Contributor
When using your map service, does the query return any features back? What's the value of featureSet for showResults? What feature type is your map layer?
0 Kudos