1

I have ArcGIS Server 9.3, and I'm trying to use the JS API. I successfully displayed the map, and I can locate and zoom to a feature based on ParcelID value. The problem is I can't highlight this parcel. I mean I tried to configure the symbol, but its not being displayed. Here's the code:

<script>
 dojo.require("esri.map");
 dojo.require("esri.layers.FeatureLayer");
 var map,featureLayer,query,sfs;
 function init() {
 map = new esri.Map("mapDiv", { 
 sliderOrientation: "horizontal"
 }); 
 var imageParameters = new esri.layers.ImageParameters();
 imageParameters.format = "PNG24"; //set the image type to PNG24, note default is PNG8.
 //Takes a URL to a non cached map service.
 var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://*******/*****/rest/services/****/MapServer", {
 "opacity":1, 
 "imageParameters":imageParameters
 });
 dynamicMapServiceLayer.setVisibleLayers([4,10,11,16]);
 map.addLayer(dynamicMapServiceLayer);
 //Locate Parcel--------
 sfs = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT,new dojo.Color([255,0,0]), 2),new dojo.Color([255,255,0,0.25]));
 featureLayer = new esri.layers.FeatureLayer("http://*****/*****/rest/services/*****/MapServer/4", {
 outFields: ["*"],
 mode: esri.layers.FeatureLayer.MODE_SELECTION
 });
 featureLayer.setSelectionSymbol(sfs);
 map.addLayers([featureLayer]);
 query = new esri.tasks.Query(); 
 query.where = "ParcelID_NS = '101010101'";
 var deferred = featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function (selection) {
 var stateExtent = selection[0].geometry.getExtent().expand(3.0);
 map.setExtent(stateExtent);
 });
 //---------------------- 
 }
 dojo.ready(init);
</script>

Any help? Thanks.

raykendo
2,1872 gold badges17 silver badges26 bronze badges
asked May 23, 2013 at 8:16
1
  • Your code is almost correct Commented May 23, 2013 at 8:49

1 Answer 1

2
 var deferred = featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function (selection) {
 var stateExtent = selection[0].geometry.getExtent().expand(3.0);
 map.setExtent(stateExtent);

try this instead of

 featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);

You can get the selected features from featurelayer.FeatureSelection() method available which will return as Graphics from that you do getExtent().expand(3.0);

answered May 23, 2013 at 8:49
3
  • I can't see any deference ? Commented May 23, 2013 at 10:09
  • Try the updated one once. For me its worked fine. Commented May 23, 2013 at 10:21
  • Is it worked for you Commented May 24, 2013 at 4:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.