Local URL not resolving correctly

I’m modifying the ‘Leaflet map’ custom component so that each marker can have a unique icon (‘map pin’.

The file structure (below) has the icons in the folder ‘map-pins’, and the icon is used in ‘get-pin2.js’ (in ‘helpers’).
File structure
File structure


Get-pin2 tries to get the icon from the file structure directly, but this causes a 400 (Bad Request) error.

The error indicates the URL is resolved incorrectly:

If I get the link of the icon from the Backendless file system, the icon is retrieved correctly:

Seems it’s not possible to read directly from the custom component file structure in this way, but I don’t understand why. Comments?

Hi @Jim_Austin

try to import the file first

import pin2Png from '../map_pins/pin2.png'

export const pin2 = new Icon({
  iconUrl: pin2Png

Thanks Vlad, that works!
Any idea why the import works when the direct assignment doesn’t? Or is this just one of those ‘that-the-way-it-is, live with it’ things?

I do not know how the Icon component works but I suspect it just passes the iconUrl property into some dom element and then a browser tries to download it in order to display it in the UI. But when the browser sees a relative URL it composes an absolute one based on the current HTML page path, that’s why you can see a URL which it not actually relative to the component.

But when you import it using JS code it goes into the component build and composes a correct URL.

So the right way is to use the import to have a correct URL.

Thanks Vlad, that makes sense …