Select to view content in your preferred language

Error loading assets when the app loads for the first time

357
1
09-27-2023 01:07 AM
ElhamAmin
New Contributor

I have a Vue application that utilizes ArcGIS JS SDK 4.26.

Within this application, I have a FeatureLayer with a UniqueValueRenderer, which is defined as follows:

	const layer = new FeatureLayer({
		title: 'Some title',
		fields: [...],
		...
		...
		renderer: new UniqueValueRenderer({
			field: 'rate',
			uniqueValueInfos: [
				new UniqueValueInfo({
					value: '1',
					symbol: new PictureMarkerSymbol({
						width: 20,
						height: 20,
						url: './assets/images/img-1.svg'
					})
				}),
				new UniqueValueInfo({
					value: '2',
					symbol: new PictureMarkerSymbol({
						width: 20,
						height: 20,
						url: './assets/images/img-2.svg'
					})
				})
			]
		})
	})



The application is deployed to a specific path, let's call it "www.example.com/sub-path/."

I've encountered an unusual behavior with the map. When the application is initially loaded, particularly after clearing the cache, the map attempts to retrieve assets from "www.example.com/assets/images/img-1.svg," resulting in 404 errors.

Strangely, this issue does not persist during subsequent page loads unless the cache is cleared again. After the initial load, the requests are correctly directed to "www.example.com/sub-path/assets/images/img-1.svg."

Can anyone shed light on this behavior and provide guidance on how to address it?

0 Kudos
1 Reply
AndyGup
Esri Regular Contributor

Hi @ElhamAmin  This sounds like a Vue.js configuration issue and not related to ArcGIS JS SDK functionality. Vue.js can have some weird caching issues. You might checkout the Vue.js documentation such as this page: https://vitejs.dev/guide/assets.html, or do some related internet searches.

0 Kudos