Showing only some points in Feature Layer on ArcGIS.Com WebMap Javascript API

3442
1
07-09-2014 12:44 PM
GaryTownsend
New Contributor

I am looking at creating a webmap which will allow users to place a point either by clicking on a map or selecting a point from a drop down which will then buffer the point. I've done something similar by pulling in featurelayers and placing them on top of a basemap. Using the Javascript API. This worked well i was trying to do something similar with a webmap in the hops of reducing the overhead of maintaining and coding 37 different category of points in the JavaScript code and off load that to the WebMap itself.

The problem i'm having is that the web map is displaying all the items and when i set the visibiilty to true on the feature, and i tried setting a null renderer with a selection symbol then just as a test arbitrarily selecting 4 points on the map. Only at first nothing rendred. Removing the Null renderer shows all the points and changes the symbols for the ones i've passed the object ids for.

So in the end what i would hope to be able to do is hide any points outside of a buffer area using the web map and am looking for some help in that direction.


require([
   "dojo/parser", "dijit/layout/ContentPane", "dijit/layout/BorderContainer",
   "dijit/layout/AccordionContainer", "dijit/layout/AccordionPane",
   "esri/map", "esri/arcgis/utils", "esri/config", "esri/urlUtils", "esri/tasks/query",
   "esri/layers/FeatureLayer", "esri/symbols/SimpleMarkerSymbol", "esri/renderers/SimpleRenderer",
   "esri/Color",
   "dojo/domReady!"
   ], function (
  parser, ContentPane, BorderContainer,
   AccordionContainer, AccordionPane,
   Map, arcgisUtils, esriConfig, urlUtils, Query,
   FeatureLayer,SimpleMarkerSymbol, SimpleRenderer,
   Color
   ) {
  parser.parse();

  urlUtils.addProxyRule({
  urlPrefix: "www.arcgis.com",
  proxyUrl: "/proxy/proxy.ashx"
   });
  urlUtils.addProxyRule({
  urlPrefix: "http://geoenrich.arcgis.com/",
  proxyUrl: "/proxy/proxy.ashx"
   });
  urlUtils.addProxyRule({
  urlPrefix: "http://services.arcgis.com",
  proxyUrl: "/proxy/proxy.ashx"
   });
  arcgisUtils.createMap("753dcfe7d5ee4984a281da14cef54366", "mapDiv").then(function (response) {
   var map = response.map;
  console.log(map);

   var fLayer = map.getLayer(map.graphicsLayerIds[0]);
   //var fLayer = response.itemInfo.itemData.operationalLayers[0]
   var j = 0;

   var nullSymbol = new SimpleMarkerSymbol().setSize(0);
   //fLayer.setRenderer(new SimpleRenderer(nullSymbol));
  fLayer.setVisibility(true);

   var symbolPath = "M16,1.466C7.973,1.466,1.466,7.973,1.466,16c0,8.027,6.507,14.534,14.534,14.534c8.027,0,14.534-6.507,14.534-14.534C30.534,7.973,24.027,1.466,16,1.466z M14.757,8h2.42v2.574h-2.42V8z M18.762,23.622H16.1c-1.034,0-1.475-0.44-1.475-1.496v-6.865c0-0.33-0.176-0.484-0.484-0.484h-0.88V12.4h2.662c1.035,0,1.474,0.462,1.474,1.496v6.887c0,0.309,0.176,0.484,0.484,0.484h0.88V23.622z"
   var siteSymbol = new SimpleMarkerSymbol();
  siteSymbol.setPath(symbolPath);
  siteSymbol.setColor(new Color([23, 62, 139, 1]));
  siteSymbol.size = 25;
  siteSymbol.setOutline(null);
  fLayer.setSelectionSymbol(siteSymbol);

   var objId = [504, 100, 1325, 728];
   var q = new Query();
  q.objectIds = objId;

  fLayer.selectFeatures(q, FeatureLayer.SELECTION_NEW, function (results) {
   var bob = 0;
   });

   //response.itemInfo.itemData.operationalLayers[0].selectFeatures(q, FeatureLayer.SELECTION_NEW, function (results) {

   //});



   });
   });

1 Reply
AntoonUijtdehaag
New Contributor

The folowing example shows you how to do this: Select with Feature Layer | ArcGIS API for JavaScript

0 Kudos