Select to view content in your preferred language

Mimic highlight effect / group features on map

654
6
10-26-2022 11:15 AM
GustavoMR
Emerging Contributor

I want to reproduce the exact same visual effect of highlighting a feature layer, but without using highlight. I have a map that I need to visually break out into different regions (each region multiple features / states), and I want each region to have its geographies grouped together by a surrounding border, pretty much the way highlight does (image attached).

I have tried merging the geometries together using union and creating a graphic, but the union turned out pretty messy with slivers and gaps where some of the geographies merge. I've looked at a ton of different ways to do this, but nothing works even remotely as well as highlight does. I believe i can only have one highlight per layer (that I know of), so I am looking for an alternative.

Does anyone have any advice on how to best do this?

Edit: I realize this question was more vague than I intended, so here's some more specifics:

I am working on the javascript API.

I have a custom webmap where one of the feature layers in it is "World Administrative Divisions" 

const myMap = new WebMap ({
   portalItem: {id: "XXXXX"}
})

 What I want is to visually group different states in North America into "regions". I can do it individually through highlight, as in the picture. But I would like to create multiple groups, and there is only one highlight per layer. So ideally I would want to do something like:

myMap.when((thisMap)=> {
const stateLayer = thisMap.allLayers.find((layer)=> {
layer.title === "World Administrative Divisions"
})
myView.whenLayerView(stateLayer).then((thisView) => {
thisView.highlight([1178,3736,5135,1107]) // state group 1
thisView.highlight([3518,5213,2359,3803]) // state group 2
})
}

 This obviously doesn't work, as it just adds the second group into the same highlight.

I've tried using a graphic layer to add different colored graphics for each group, but

1) it feels like overkill, to reproduce all the geometries that already exist in my feature layer

2) each feature / graphic has it's own border so you don't get the same visual impact of a single block (image of graphic approach attached as well)

Any guidance or alternatives would be greatly appreciated

0 Kudos
6 Replies
JayakumarPD
Frequent Contributor

Is it possible to share the code, if you are trying with ESRI java script  api.  I will try.

The screen shot provided, is not giving any Idea, in which you are working. 

I think, you have to query the geometries --> where condintion == particular region 

will get a featureSet and apply the symbology as highlight.

Just for visualising, altering the nature of geometry is not advised.

 

GustavoMR
Emerging Contributor

Thanks for the reply, I realize now I did not provide enough context and information, so I've re-stated the question.  If I understand correctly , I've tried a similar approach, but a layer can only have one highlight and what I want is to have one "highlight effect" (not necessarily a highlight itself) per group of features. Basically I am trying to partition the map of the United States into 4 regions and have each region surrounded by a border in the same way highlight does.

0 Kudos
vinayvamshikrishna
New Contributor

hi jayakumar can u pls ping because i hve doubt in  api arcgis developer 

0 Kudos
JayakumarPD
Frequent Contributor

hi, you can share the code, put the comment. I will try to understand.

0 Kudos
JoelBennett
MVP Regular Contributor

I don't think you're going to be able to avoid the overkill you mentioned, because using a GraphicsLayer is about the only way to accomplish what you're trying to do.

You might consider simply removing the borders from the symbols so they don't appear to be split up.  After all, if you have two regions right next to each other, their borders will overlap, and may not be the look you're trying to achieve.

The problem you're having with slivers and gaps after unioning could be related to the fact that FeatureLayers retrieve generalized geometries from the server based upon the current map scale.  This helps reduce the amount of network traffic and processing required in order to display a feature, but it also means the client doesn't usually have the true feature geometry.  If you want to union these features together as neatly as possible, you'll need to make sure you're retrieving the actual geometries from the server.  This would likely require the use of the objects in the esri/rest namespace (query, etc).

GustavoMR
Emerging Contributor

Thanks for your reply, I was leaning to this same conclusion, but I was hoping there was some other method I've missed, specially since highlight seems to do it really well, so maybe the same logic of how it works "under the hood" could be reproduced.

Another consideration why I would prefer to have actual grouped geometries is that I would much rather show the territory divisions with a border rather than with a fill color. I will have to make different maps with different groupings for different users, so if I use fill then I need to build a logic for automatically generating colors for each region (that won't look terrible), vs border where I could just use one standard color since the border is the visual divider instead of the color itself.

If there is no way around it though, I will go with this option.

0 Kudos