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]));
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?
<!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>
Great , I know i have to use query task to query the service.But my question is if i query http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/2which has reqion as fields that it return , i will get string but how will i use this string to highlight map , how will i identify the reqion or how i get that reqion object.Plz help.Also can i query only feature layer , i check in ArcGISDynamicMapServiceLayer there is no help for query.
Thanks a lot, by the highlighting part is where i am struck actually , the example that u pointed out get the region attribute when u click on map but here what i want is vice versa, i want to provide region and highlight , this is very important for me so please point out something.
1)DO i have to choose only from existing rest service from arcgis , cant i create myself services.
2) I need a world map where i can identify each country by an two letter word id , so that if i want to highlight us , then i can something like dojo.byId('us") and apply some graphic code to highlight it.
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) { // clears current selection map.graphics.clear(); // create new graphic with selected graphic's geometry var graphic = new Graphic(evt.graphic.geometry); // create a new symbol for the graphic 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])); // add symbol to the graphic graphic.setSymbol(sfs); // add the graphic to the map map.graphics.add(graphic); }); });
require(["dojo/on"], function(on){ on(fl, "click", function(evt) { // do something with evt.graphic - get it's attributes and display them somewhere, edit it's symbol, reshape it etc. }); });
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.