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.
-
Your code is almost correctJagadesh– Jagadesh2013年05月23日 08:49:36 +00:00Commented May 23, 2013 at 8:49
1 Answer 1
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);
Explore related questions
See similar questions with these tags.