Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-leaflet with Whitenoise messes up marker-icon.png and marker-shadow.png #188

Closed
Matbj opened this issue May 2, 2017 · 11 comments
Closed

Comments

@Matbj
Copy link

Matbj commented May 2, 2017

I'm using Whitenoise for static file serving (because reasons) and I think that the regex that is being used here:
.../staticfiles/leaflet/leaflet-src.js:6325
path.replace(/^url\([\"\']?/, '').replace(/marker-icon\.png[\"\']?\)$/, '') : '';
messes up when used with Whotenoise because it tries to fetch the file like this:

"GET /static/leaflet/images/marker-icon.2273e3d8ad92.png%22)marker-icon.png HTTP/1.1" 404 146 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
"GET /static/leaflet/images/marker-icon.2273e3d8ad92.png%22)marker-shadow.png HTTP/1.1" 404 148 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
xusy2k added a commit to xusy2k/django-leaflet that referenced this issue Jul 23, 2017
Whitenoise append a suffix not contemplated in replace
@xusy2k
Copy link
Contributor

xusy2k commented Jul 23, 2017

Same problem here, it's not django-leaflet's bug. It comes from Leaflet.

For fixing it's enough replacing at line

return path.indexOf('url') === 0 ?
            path.replace(/^url\([\"\']?/, '').replace(/marker-icon\.png[\"\']?\)$/, '') : '';

for this new one:

return path.indexOf('url') === 0 ?
            path.replace(/^url\([\"\']?/, '').replace(/marker-icon[\.[a-zA-Z0-9]*\.png[\"\']?\)$/, '') : '';

I'm very newbie with GIS, but I've done tests with my map with and without Whitenoise and it worked in both cases.

xusy2k added a commit to xusy2k/Leaflet that referenced this issue Jul 23, 2017
Whitenoise append a suffix not contemplated in replace

Found at makinacorpus/django-leaflet#188
xusy2k added a commit to xusy2k/django-leaflet that referenced this issue Jul 23, 2017
@Gagaro Gagaro closed this as completed in a43acc5 Aug 7, 2017
@Gagaro
Copy link
Member

Gagaro commented Aug 7, 2017

Merged in #197

@olawale1rty
Copy link

olawale1rty commented May 30, 2020

@xusy2k
I just deployed my application using heroku when i noticed this error, but i cant find the leaflet file you said we should edit in my folders. I am using django-leaflet and geodjango for my application. Please, i will appreciate if you have a way of going through this.

@xusy2k
Copy link
Contributor

xusy2k commented May 31, 2020

Hi @olawale1rty!
The files you are looking for are located at this commit xusy2k/django-leaflet@4fbf80d, but right now they are merged into master.

Maybe you can keep an eye to #268 and its files, a90098d

@olawale1rty
Copy link

olawale1rty commented Jun 9, 2020 via email

@faprietoml
Copy link

No solutions for this issue?

@faaizajaz
Copy link

faaizajaz commented Nov 26, 2020

No solutions for this issue?

@faprietoml You need to build leaflet from source yourself. See commits in: https://github.com/faaizajaz/django-leaflet

@faprietoml
Copy link

No solutions for this issue?

@faprietoml You need to build leaflet from source yourself. See commits in: https://github.com/faaizajaz/django-leaflet

Thank you

@claudep
Copy link
Contributor

claudep commented Nov 27, 2020

@faaizajaz can we see a diff of your patch on the non-minified leaflet source?

@faaizajaz
Copy link

@faaizajaz can we see a diff of your patch on the non-minified leaflet source?

I based my patch on this PR: a90098d

Unfortunately this needs to be done manually every time there is a new leaflet release (unless they have fixed it in the last month or so).

@claudep
Copy link
Contributor

claudep commented Nov 27, 2020

OK, then I think we could store the patch to ...-src.js somewhere in django-leaflet source tree, then add a README.upgrade in leaflet/static/leaflet/ to document it (and a command to produce a minified version from the patched file). Then ideally a regression test should be added too, if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants