Webapp- Show points within a selected polygon

5891
10
Jump to solution
12-31-2014 09:11 AM
RickeyFight
MVP Regular Contributor

I have over 3 million points. I cannot have my server displaying all these points on a map a the same time.

What I want to do is when a building is selected, show all points within that polygon.

I know about this example:

Select with Feature Layer | ArcGIS API for JavaScript

I am not sure that will work because I don't want a buffer I want to use another Layer.

Thank you

0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

Yep you can use the same idea as the sample you linked to but instead of using a buffer you'll just use the geometry of the other layer. Here's an example that selects all the points within a census block group.

Select with feature layer

If you look at the code you'll see that we setup a click handler for the block feature layer and when its clicked we query the point feature layer using the clicked geometry. 

View solution in original post

10 Replies
KellyHutchins
Esri Frequent Contributor

Yep you can use the same idea as the sample you linked to but instead of using a buffer you'll just use the geometry of the other layer. Here's an example that selects all the points within a census block group.

Select with feature layer

If you look at the code you'll see that we setup a click handler for the block feature layer and when its clicked we query the point feature layer using the clicked geometry. 

RickeyFight
MVP Regular Contributor

That should work!

Thank you!

0 Kudos
RickeyFight
MVP Regular Contributor

I was wondering if there is a way to have the selected census block highlighted as well?

It would be nice to know the boundary is for the block.

Is there a reason why when a geocoder is added it will not zoom to location?

Thank you!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rickey,

   Here is an updated version that adds the select block as well

Select with feature layer

RickeyFight
MVP Regular Contributor

Robert Scheitlin, GISP

That is exactly what I was looking for thank you!

0 Kudos
RickeyFight
MVP Regular Contributor

So I am using polygons not points. Some polygons (soils) overlap some of the boundaries(taxlots).

For the life of me I cannot figure out how to change the color to indicate what polygon is selected(cyan outline).

It is confusing because there are so many features being selected.

The red taxlot is a boundary. Then two different features (soils) overlap that polygon are selected, indicated by a red dash.

When I select either polygon a cyan outline appears. This works when the map is zoomed out but when it is zoomed in it is impossible to tell what one is selected.

How do i change the color of the soils layer to indicate which one is selected?

Thank you

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rickey,

   If I am understanding your concern then all you need to do is set the soil layer selection symbol. Look in the existing code for "setSelectionSymbol" for an example of the code syntax.

RickeyFight
MVP Regular Contributor

Robert,

Thank you for the quick reply!

I found the "setSelectionSymbol" you are talking about. When I add a color it changes the color of both polygons(soils) not the selected one.

 

   // selection symbol used to draw the selected census block points within the buffer polygon

                    var symbol3 = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

                    new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,

                    new Color([247, 34, 101]), 2), new Color([247, 34, 101, 0.25]));

     censusPoints.setSelectionSymbol(symbol3);

I am looking for the selected one (cyan border) to change fill color when selected.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rickey,

   You have do the setSelectionSymbol for the soils layer the cyan outline is the selection symbol.

0 Kudos