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 />
Solved! Go to Solution.
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
You can use symbolUtils.renderPreviewHTML for something like this.
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
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