Hi, I am able to set spatial filters by providing input geometry and spatial relationship to a FeatureLayer in snapshot mode in silverlight api. How do i do this in JSAPI 2.0? The feature layer doesnt have any geometry property. Is there an elegant way of achieving this by some other means?regardsRavi
I have noticed that jsapi 2.0 provides a datalayer class (esri.tasks.DataLayer) which has geometry and spatialrelationship property. But I am unable to get it to work and couldnt find any sample which uses a datalayer. Ravi
Ben,I am using proxy file for this functionality and i have fixed my issue, now i am able to apply spatial filter on a feature layer.
Hi Kelly,I have tried the following code and it was working fine in my scenario. But when i buffer a point for a radius of 10 KM using geometry service and pass the resultant polygon (in my case a circle) to the query filter it doesn't filter. But the same polygon if i convert to extent it works fine. Any idea why this behavior is?Regards,Ravi.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>FeatureLayer On Demand</title> <script type="text/javascript">djConfig = { parseOnLoad:true };</script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0"></script> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css"> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.layers.FeatureLayer"); dojo.require("dijit.form.Button"); dojo.require("dijit.Dialog"); var mapLayers = []; //array of layers in client map var map; function init() { var extent = new esri.geometry.Extent({"xmin":-13337231.937022427,"ymin":3914529.1302062804,"xmax":-12909184.578625461,"ymax":4220277.2433469705,"spatialReference":{"wkid":102100}}); map = new esri.Map("map", { extent:extent}); dojo.connect(map, "onLoad", initOperationalLayer); var imagery = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"); map.addLayer(imagery); } function initOperationalLayer(map) { var featureLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0",{ mode: esri.layers.FeatureLayer.MODE_SELECTION, outFields: ["*"] }); map.addLayer(featureLayer); var extent = new esri.geometry.Extent({"xmin":-13228997.10497058,"ymin":3961002.843403707,"xmax":-13014973.425772188,"ymax":4113876.899973986,"spatialReference":{"wkid":102100}}); var query = new esri.tasks.Query(); query.geometry = extent; featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW); } dojo.addOnLoad(init); </script> </head> <body class="tundra"> <div style="position:relative;"> <div id="map" style="width:700px; height:500px; border:1px solid #000;"></div> </div> </body> </html>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.