evidence icon indicating copy to clipboard operation
evidence copied to clipboard

[Bug]: Using a file path in geoJsonUrl does not work

Open micahchoo opened this issue 4 months ago • 4 comments

Describe the bug

I have tried adding inside a static folder, inside the pages collection, inside the sources folder, without quotes, with quotes. Just can't seem to make it work

Steps to Reproduce

use a filepath with geoJsonUrl

Logs


System Info


Severity

annoyance

Additional Information, or Workarounds

No response

micahchoo avatar Oct 04 '25 20:10 micahchoo

Should be inside the static folder for sure.

Link URL is relative to static so "/hello.geojson" is /static/hello.geojson

Check the Dev tools console for errors? It might be choking when reading the file

archiewood avatar Oct 04 '25 20:10 archiewood

When i add it to static, it looks inside the collection where the page is to find a static folder examples: https://micahchoo.github.io/DataViz-for-Indian-Cities/PCMC/index%20copy/ https://github.com/micahchoo/DataViz-for-Indian-Cities/blob/master/pages/PCMC/index%20copy.md

it doesn't find the file at all 1. XHRGET http://localhost:3000/pcmcg.geojson [HTTP/1.1 404 Not Found 1ms]

2.Adding static explicitly XHRGET http://localhost:3000/DataViz-for-Indian-Cities/PCMC/index copy/static/pcmcg.geojson [HTTP/1.1 404 Not Found 2ms]

I don't know if this is related but I also get when using geoJsonUrl="/pcmcg.geojson"

Failed to load GeoJSON at URL '/pcmcg.geojson': SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data EvidenceMap.js:461:13

micahchoo avatar Oct 04 '25 20:10 micahchoo

Seems like it is failing to parse the geojson. Have you tried any other files?

Also if you are hosting on GitHub pages it's possible that you will need to add the base path using the addBasePath utility

archiewood avatar Oct 04 '25 23:10 archiewood

I tried both of these

<Image 
    url="/wordmark-gray-800.png"
    description="Sample placeholder image"
    height=80
/>

![Image](/wordmark-gray-800.png)

The first one gave me a build error but the second one didn't

                         ^
Error: 404 /wordmark-gray-800.png does not begin with `base`, which is configured in `paths.base` and can be imported from `$app/paths` - see https://svelte.dev/docs/kit/configuration#paths for more info (linked from /DataViz-for-Indian-Cities/PCMC/index_copy/)
To suppress or handle this error, implement `handleHttpError` in https://svelte.dev/docs/kit/configuration#prerender
    at file:///home/runner/work/DataViz-for-Indian-Cities/DataViz-for-Indian-Cities/node_modules/@sveltejs/kit/src/core/config/options.js:203:13

Also I have added the basepath in my config

micahchoo avatar Oct 04 '25 23:10 micahchoo