Great I was able to do that ,below is the code<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Feature Layer Only Map</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="http://js.arcgis.com/3.6/"></script>
<script>
require([
"dojo/dom-construct",
"esri/map",
"esri/layers/FeatureLayer",
"esri/geometry/Extent",
"esri/InfoTemplate",
"dojo/domReady!"
], function(
domConstruct,
Map,
FeatureLayer,
Extent,
InfoTemplate
) {
var bounds = new Extent({
"xmin":-16045622,
"ymin":-811556,
"xmax":7297718,
"ymax":11142818,
"spatialReference":{"wkid":102100}
});
var map = new Map("map", {
extent: bounds
});
var url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/2";
var template = new InfoTemplate("World Regions", "Region: ${REGION}");
var fl = new FeatureLayer(url, {
id: "world-regions",
//infoTemplate: template
});
require(["dojo/on", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "esri/graphic"], function(on, SimpleFillSymbol, SimpleLineSymbol, Color, Graphic) {
on(fl, "click", function(evt) {
var queryTask = new esri.tasks.QueryTask(url);
//build query filter
var query = new esri.tasks.Query();
query.returnGeometry = true;
query.where = "REGION='Central America'";
dojo.connect(queryTask, "onComplete", function(featureSet) {
map.graphics.clear();
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_FORWARD_DIAGONAL, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
//QueryTask returns a featureSet. Loop through features in the featureSet and add them to the map.
dojo.forEach(featureSet.features,function(feature){
var graphic = feature;
graphic.setSymbol(sfs);
map.graphics.add(graphic);
});
});
queryTask.execute(query);
});
});
map.addLayer(fl);
}
);
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
do i have to query only the feature layer is there an option for ArcGisDynamicMapService layer.Secondly for highlighting is there any alternative way is it only this way?