Select to view content in your preferred language

return layer symbol url

595
3
Jump to solution
02-09-2022 10:02 AM
KevinDunlop
Occasional Contributor III

Hi,

I am looking for a method that gets the FeatureLayer symbol URL either from the Feature Service itself or the FeatureLayer.  My goal is to use that url to change the src  on a <img> value that I use in a different part of my web application.  I haven't been able to find a Javascript 4.x method that returns this.

Can anyone point me in the right direction

 

const VBA = new FeatureLayer({
url: "https://gis.va.gov/server/rest/services/PROJECTS/VBA_VHA_NCA_Regional_and_Major_Facilities/FeatureServer/0",
title: "VBA"
});

document.getElementById("VBA_Img").src=VBA.renderer.symbol.url;
<span id="VBA_Text">VBA</span><img id="VBA_Img" /><br />

 

 

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor II

You may have to wait for the view or layer to be finished. Also make sure it's an image, and not svg, depending on how it was created. This sample works grabs the layer and iterates the uniqueValueInfos

https://codepen.io/odoe/pen/rNYGjVg?editors=1000

View solution in original post

0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor II
0 Kudos
KevinDunlop
Occasional Contributor III

Hi,

Thanks for the advise but it didn't work.  It also made it so the LayerList no longer can toggle the visibility of it.  Any suggestions?

 

const VBA = new FeatureLayer({
   url: "https://cdw.maps.va.gov/server/rest/services/Map/FeatureServer/6",
   visible: true
   });

map.add(VBA);

const VBAsymbol = VBA.renderer.symbol.clone();
symbolUtils.renderPreviewHTML(VBAsymbol, {
   node: document.getElementById("VBA_Img"),
   size: 8
   });

 

<span id="VBA_Text">VBA Regional Offices</span><img id="VBA_Img" /><br />

Thanks

 

0 Kudos
ReneRubalcava
Frequent Contributor II

You may have to wait for the view or layer to be finished. Also make sure it's an image, and not svg, depending on how it was created. This sample works grabs the layer and iterates the uniqueValueInfos

https://codepen.io/odoe/pen/rNYGjVg?editors=1000

0 Kudos