AnsweredAssumed Answered

Zoom to Issues

Question asked by jay.kapalczynski on Apr 4, 2017
Latest reply on Apr 4, 2017 by evtguy

I included the relevant code I think for this issue....

 

I have my Map

I am setting the spatial reference of the query results

Using the results to create a new graphics Layer

 

The Graphics are located in the correct position so that works fine... 

BUT when the below runs it zooms off the coast of Africa.  I know this is a Spatial Reference issue but not sure where and how to set it...

Thoughts?

 

var extGraphics = graphicsUtils.graphicsExtent(map.graphics.graphics);
map.setExtent(extGraphics);

 

 

 

    //SET THE MAP
    var map = new Map("map", {
        basemap: "dark-gray",
        center: [-79.665, 37.629],
        zoom: 8,
        logo: false,
        showLabels: true
    });


      // QUERY FOR County and Squad
      var queryTask = new QueryTask("https://vafwisdev.dgif.virginia.gov/arcgis/rest/services/Projects/Summons/FeatureServer/5");
      var query = new Query();
       query.outSpatialReference = {wkid: 4326}; //4326 //102100 //3857
       query.returnGeometry = true;

/// SNIP

      var countiesGraphicsLayer = new GraphicsLayer({opacity:0.75});

      //This is the click event for the graphics on the map
      countiesGraphicsLayer.on("click", selectGrid);
      map.addLayer(countiesGraphicsLayer);

/// SNIP

        arrayUtils.map(results.features, function(feature) {
          feature.setSymbol(symbol);
          feature.setInfoTemplate(infoTemplate);
          countiesGraphicsLayer.add(feature);
          
          var featureAttributes = feature.attributes;
          for (var attr in featureAttributes) {
            resultItems.push("<b>" + attr + ":</b>  " + featureAttributes[attr] + "<br>");
          }
          resultItems.push("<br>");
        });
        dom.byId(ActivePane).innerHTML = resultItems.join("");

          var extGraphics = graphicsUtils.graphicsExtent(map.graphics.graphics); 
        map.setExtent(extGraphics);

/// SNIP

Outcomes