@@ -131,32 +131,27 @@ async function fetchJsonData(url) {
131131async function fetchBlob ( url , monumentFunction ) {
132132 if ( ! url || typeof url !== 'string' ) return
133133
134- try {
135- const response = await fetch ( url , { method : 'get' , mode : 'cors' } )
136- if ( ! response . ok ) {
137- console . warn ( `${ url } returned HTTP status code ${ response . status } ` )
138- return
139- }
140- const blob = await response . blob ( )
141- const imageUrl = URL . createObjectURL ( blob )
142- const imageElement = document . createElement ( 'img' )
143- imageElement . src = imageUrl
144- imageElement . setAttribute ( 'alt' , monumentFunction || 'Denkmalschutz' )
145-
146- const divElement = document . createElement ( 'div' )
147- divElement . classList . add ( 'px-3' , 'py-2' , 'w-full' , 'text-xs' , 'text-gray-100' , 'bg-gray-600' )
148- divElement . innerText = 'Foto © Landesamt für Denkmalpflege'
149-
150- const container = document . querySelector ( '#detailImage' )
151- if ( ! container ) {
152- console . error ( 'Element #detailImage not found' )
153- return
154- }
155- container . appendChild ( imageElement )
156- container . appendChild ( divElement )
157- } catch ( error ) {
158- console . error ( 'Error in fetchBlob:' , error )
134+ const container = document . querySelector ( '#detailImage' )
135+ container . innerHTML = ''
136+
137+ const imageElement = document . createElement ( 'img' )
138+ imageElement . src = url
139+
140+ imageElement . onload = ( ) => { imageElement . classList . add ( 'loaded' ) }
141+ // imageElement.onerror = () => { container.classList.add('hidden') }
142+ imageElement . setAttribute ( 'alt' , monumentFunction || 'Denkmalschutz' )
143+
144+ const divElement = document . createElement ( 'div' )
145+ divElement . classList . add ( 'px-3' , 'py-2' , 'w-full' , 'text-xs' , 'text-gray-100' , 'bg-gray-600' )
146+ divElement . innerText = 'Foto © Landesamt für Denkmalpflege'
147+
148+ if ( ! container ) {
149+ console . error ( 'Element #detailImage not found' )
150+ return
159151 }
152+
153+ container . appendChild ( imageElement )
154+ container . appendChild ( divElement )
160155}
161156
162157async function fetchMonumentPointsByBounds ( ) {
0 commit comments