Select to view content in your preferred language

Using Web Components via 4.33 using Javascript and NOT static HTML

90
1
yesterday
dtstopper
Emerging Contributor

Hello, I have a question about using the new 4.33 framework.  Currently I'm using widgets that are deprecated such as ScaleBar and BasemapGallery.  I have no problem putting these on my map when I dynamically render it in JS, however when I place the web components statically in the html they get lost when I render the map div with changes.  I have looked everywhere but can only find static samples which are useless when compared to widgets generated on the fly.  Can anyone instruct me on how to dynamically generate web components via JavaScript? 

0 Kudos
1 Reply
Sage_Wall
Esri Regular Contributor

Hi @dtstopper ,

You can use `document.createElement("arcgis-map")` in your javascript code.  I've got a github repo I use for testing stuff where I create everything programmatically and not in the HTML markup.  Hope this helps.

https://github.com/sagewall/vite-map-components/blob/main/src/main.ts