Here is sample code,
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=basemap-gallery
if you move
<arcgis-basemap-gallery position="top-right"></arcgis-basemap-gallery>
outside of
</arcgis-map>
tag,
base map gallery will be disabled automatically.
see my screen.
even in js, I set
Solved! Go to Solution.
the sample works fine, is because
<arcgis-basemap-gallery position="top-right"></arcgis-basemap-gallery>
is inside of
</arcgis-map>
tag,
When working with the map-components, if a component is not a child of a map or scene component, you can use a "reference-element" attribute to associate them.
Here is how to use reference element,
https://developers.arcgis.com/javascript/latest/programming-patterns/
warning: when you use reference element in html tag, you must use exact word "reference-element"
when you use reference element in javascript, must use exact word "referenceElement"
They are not interchangable, otherwise, will not work.
Based on this theory, I correct the online sample as following
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=basemap-gallery
"reference-element" is the attribute name, only to be used declaratively.
"referenceElement" is the property name, which be accessed via "element.referenceElement". It would also be used in jsx syntax for various UI libraries.
https://developers.arcgis.com/javascript/latest/programming-patterns/#attributes-and-properties
the sample works fine, is because
<arcgis-basemap-gallery position="top-right"></arcgis-basemap-gallery>
is inside of
</arcgis-map>
tag,
When working with the map-components, if a component is not a child of a map or scene component, you can use a "reference-element" attribute to associate them.
based on your advice, I test it like this, it does not work. Unless I did it not the way you means. Please use this online sample as test, explain what you exactly means, how to use reference element?
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=basemap-gallery
Here is how to use reference element,
https://developers.arcgis.com/javascript/latest/programming-patterns/
warning: when you use reference element in html tag, you must use exact word "reference-element"
when you use reference element in javascript, must use exact word "referenceElement"
They are not interchangable, otherwise, will not work.
Based on this theory, I correct the online sample as following
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=basemap-gallery
"reference-element" is the attribute name, only to be used declaratively.
"referenceElement" is the property name, which be accessed via "element.referenceElement". It would also be used in jsx syntax for various UI libraries.
https://developers.arcgis.com/javascript/latest/programming-patterns/#attributes-and-properties