How to add a custom marker with given renderer for features on portalitem?

649
7
Jump to solution
05-27-2020 06:36 AM
ChristianBischof
Esri Contributor

Using JS API 4.15

I have a portalItem which comes with already rendered markers for its features (3 feature layers). Those markers have shadows which shouldn't be "clickable" to trigger the popup.

So the idea is to put our own markers (for which we have renderer.json files) exactly on all of those provided markers of the portalItem so that we have access to all those markers and make the provided markers not clickable.

So basically we want to put our own markers with the according renderer.json on top of the given markers from the portalItem.

If anybody could provide some sample code, instructions or suggestions I'd be glad!

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
Egge-JanPollé1
MVP Regular Contributor

Hi Christian Bischof,

Maybe you can add the feature layers twice. Once the original one, the one with the shadow, and another one on top, with your own rendering.

In that case you can set popupEnabled to false for the first layer and to true for the second one. This should give the desired effect.

Please note: you may also wish to set the listMode to false for the bottom layer, just to avoid that the layer appears twice in the LayerList (if you have any in your app).

Does this solve your issue?

BR,

Egge-Jan

View solution in original post

7 Replies
Egge-JanPollé1
MVP Regular Contributor

Hi Christian Bischof,

Would this tutorial Style feature layers | ArcGIS API for JavaScript 4.15 answer your question?

BR,

Egge-Jan

ChristianBischof
Esri Contributor

Thanks Egge-Jan Pollé‌ this was helpful, but I am still a bit stuck with this "clickable are thing". Let's say I wanted to make only the white man in the image of the trailheadslayer to be the trigger for the popup as demonstrated in the clickablearea.png file I added to the question. So basically if the area outside of the red box is clicked nothing happens, but if the click is inside of it the popup opens.

0 Kudos
Egge-JanPollé1
MVP Regular Contributor

Hi Christian Bischof,

Maybe you can add the feature layers twice. Once the original one, the one with the shadow, and another one on top, with your own rendering.

In that case you can set popupEnabled to false for the first layer and to true for the second one. This should give the desired effect.

Please note: you may also wish to set the listMode to false for the bottom layer, just to avoid that the layer appears twice in the LayerList (if you have any in your app).

Does this solve your issue?

BR,

Egge-Jan

View solution in original post

ChristianBischof
Esri Contributor

thanks Egge-Jan Pollé‌ I am currently trying to make exactly this approach work haha  I'll share my code snippet when I'm done - if anybody else's faster, feel free to contribute

Additoinally maybe it's worth mentioning that the webmap is a portalItem and already comes with some feature layers added to it.

0 Kudos
ChristianBischof
Esri Contributor

hi Egge-Jan Pollé‌ your suggestion was helpful and I was able to implement it, but it didn't fix my issue because the popup opens generally not only at an exact click on the feature/it's marker, but also if the click event happens "somewhere very close to it". Eventually I wasn't able to achieve what I wanted: define a certain area which is clickable to trigger the popup.

Anyway I guess if the markers would be bigger than this approach could work for others

Egge-JanPollé1
MVP Regular Contributor

Hi Christian Bischof,

Actually, that's what I asked myself from the first time I saw your question: why would you want to have a marker that is partly clickable, and partly non-clickable at all?!

From an end user perspective: it would drive me nuts if I clicked on a marker (because visually it is just one marker) and it would only react when I clicked in a particular part of it.

That's why click events which happen "somewhere very close to it" are also honored. It would discourage the users of your app if they have to click 10 or 20 times to open a popup...

So, anyways, you could try to use the suggestion which I gave above, but most probably it is best not to use it at all.

BR,

Egge-Jan

ChristianBischof
Esri Contributor

Egge-Jan Pollé‌ that's as well my opinion but it was a wish from a customer. Those moments when I ask myself "why am I doing this" haha