remove defaultSymbol

547
2
11-11-2010 12:39 AM
simonmiles
New Contributor II
probably very simple, but i cant work it out. I want to remove the defaultSymbol statement from the below JS, so that i can see the symbols as defind in my arcmap project. When i do remove the statement, i cant see the layer in my map. Any ideas.

Thanks

Si


dojo.require("esri.map");
      dojo.require("esri.tasks.query");

      //global variables
      var map, defaultSymbol, resultTemplate;

      function init() {
        var initExtent = new

esri.geometry.Extent({"xmin":467047.747001408,"ymin":164818.857300987,"xmax":519157.538720992,"ymax":187956.716076704,"spatialReference":{"wkid":27700}});
        map = new esri.Map("map",{extent:initExtent});

        //Add the world street map layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service   
       
   var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://****/ArcGIS/rest/services/basemapping_v2/MapServer");
        map.addLayer(basemap); 

        //initialize symbology
        defaultSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0,0,255]));
       
        //initialize & execute query
        var queryTask = new esri.tasks.QueryTask("http://****/ArcGIS/rest/services/Live/****/MapServer/0");
        var query = new esri.tasks.Query();
        query.where = "DATE_ = 'November'";
        query.outSpatialReference = {wkid:27700};
        query.returnGeometry = true;
        query.outFields = ["*"];
        queryTask.execute(query, addPointsToMap);

        //info template for points returned
  resultTemplate = new esri.InfoTemplate("${NAME}",
      "<tr><td>${ROADNAME}</tr></td><br/>"
           + "<tr><td>${VILLAGE}</tr></td><br/>"
            + "<tr><td>${TOWN}</tr></td><br/>"
           + "<tr><td>${PC}</tr></td><br />"
           + "<tr><td>tel : ${TEL}</tr></td><br />"
           + "<tr><td>visit website : <a href=${WEB} target=_blank>click here</a></tr></td><br />"
           + "<tr><td>view ofstead report : <a href=${OFSTEAD} target=_blank>click here</a></tr></td><br />");
        




      }

      //add points to map and set their symbology + info template
      function addPointsToMap(featureSet) {
        var features = featureSet.features;
        for (var i=0, il=features.length; i<il; i++) {
          map.graphics.add(features.setSymbol(defaultSymbol).setInfoTemplate(resultTemplate));
        }
            }

      dojo.addOnLoad(init);
0 Kudos
2 Replies
AxelSchaefer
New Contributor II
I don't understand exactly what you are trying to do, but I guess that you want to switch off the graphics layer where you have put your symbols to see the original basemap.

Try the graphicsLayer.hide() method (map.graphics.hide()).

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/layer.htm#hide
0 Kudos
TerryGiles
Occasional Contributor III
You have to set some sort of symbol for the graphics being added to the map.  What if you change defaultSymbol to be transparent?  dojo colors can be constructed with an alpha paramter ranging from 0 = transparent to 1.0.

new dojo.Color([r,g,b,a])

defaultSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0,0,255,0]));
0 Kudos