Select to view content in your preferred language

Filtering layer, please I newbie !!!

827
3
09-22-2010 06:50 PM
ChristianBocaz
Emerging Contributor
Please, I need help with this problem.
I have a layer with 5 lines as roads, and all of they with a geocode.
Also, i have a mxd as a map service in a ArcGis Server 9.3.
I need to put the map of the service  in a webpage across Esri Javascript, but filtering the roads across a GET or POST variable and highlight this road.

Please....help me !! and sorry for my english.


Christian
0 Kudos
3 Replies
ChristianBocaz
Emerging Contributor
Please, I need help with this problem.
I have a layer with 5 lines as roads, and all of they with a geocode.
Also, i have a mxd as a map service in a ArcGis Server 9.3.
I need to put the map of the service  in a webpage across Esri Javascript, but filtering the roads across a GET or POST variable and highlight this road.

Please....help me !! and sorry for my english.


Christian


Hi, I found the way to make a query and create a symbol over tha roads...but,,, I can't make that after query, center and zoom to the query result....
Please, can you help me ??...

here is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>test</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
    <script type="text/javascript">
   dojo.require("esri.map");
      dojo.require("esri.tasks.query");
   dojo.require("esri.symbol");
      dojo.require("esri.layers.agstiled");
      dojo.require("esri.toolbars.draw");   
   var map;
      var myQueryTask, myQuery;
   var infoTemplate;
   var symbol;
      function init() {
  //create map and add layer
  map = new esri.Map("mapDiv");
  var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis/ArcGIS/rest/services/MOP/MapServer");
  map.addLayer(layer);   
        //build query
        myQueryTask = new esri.tasks.QueryTask("http://gis/ArcGIS/rest/services/MOP/MapServer/10");

        //build query filter
        myQuery = new esri.tasks.Query();
        myQuery.returnGeometry = true;
        myQuery.outFields = ["CodUnico","Nombre","Dire"];
    //initialize InfoTemplate
  infoTemplate = new esri.InfoTemplate("${CodUnico}", "Nombre : ${Nombre}<br/> Dire : ${Dire}");
 
  //create symbol for selected features
  symbol = new esri.symbol.SimpleMarkerSymbol();
  symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE);
  symbol.setSize(10);
  symbol.setColor(new dojo.Color([255,0,0,0.5]));
  
      }

      function execute(CodUnico) {
        myQuery.where = "CodUnico like '%" + CodUnico + "%'";
        //execute query
        myQueryTask.execute(myQuery,showResults);
      }

      function showResults(myFeatureSet) {
        var s = "";
        for (var i=0, il=myFeatureSet.features.length; i<il; i++) {
          var featureAttributes = myFeatureSet.features.attributes;
          for (att in featureAttributes) {
            s = s + "<strong>" + att + ": </strong>" +
   featureAttributes[att] + "<br />";
          }
        }
        dojo.byId("info").innerHTML = s;
    //remove all graphics on the maps graphics layer
    map.graphics.clear();

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

    //Loop through each feature returned
    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);  
      }
   
  }
      dojo.addOnLoad(init);
    </script>
  </head>
  <body>
    <form action="">
      Geocodigo DAP :
      <input type="text" id="CodUnico" value="DAP101012" />
      <input type="button" value="Get Details"
onclick="execute(dojo.byId('CodUnico').value);" />
    </form>
    <br />
    <br /><div id="mapDiv" style="margin:auto;width:97%;border:1px solid #000;"></div>
    <div id="info" class="tundra" style="padding:5px; margin:5px; background-color:#eee;"></div>
   
  </body>
</html>



any idea ?
0 Kudos
TimRourke
Emerging Contributor
Christian,

If you put the graphics in an array as you add them to the map, you can get the extent of the graphics using esri.graphicsExtent.


See:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/namespace_esri.htm#esr...
0 Kudos
ChristianBocaz
Emerging Contributor
finally I found the way to make it.
But now, i have to draw N objects as Points, Polygon and Polylines all in the same query task.
My problem here is about how can set the extent for the N objects.....like ArcMap do it ?

some one can help me ?
0 Kudos