makinacorpus / django-leaflet

Use Leaflet in your Django projects
GNU Lesser General Public License v3.0
716 stars 282 forks source link

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

Closed Matbj closed 7 years ago

Matbj commented 7 years ago

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 commented 7 years ago

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.

Gagaro commented 7 years ago

Merged in #197

olawale1rty commented 4 years ago

@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 commented 4 years ago

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

Maybe you can keep an eye to #268 and its files, makinacorpus/django-leaflet@a90098d7dcdbbcdfed329300d568c9691da21860

olawale1rty commented 4 years ago

Thank you very much sir.

On Sunday, May 31, 2020, Xus Zoyo notifications@github.com wrote:

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

Maybe you can keep an eye to #268 https://github.com/makinacorpus/django-leaflet/pull/268 and its files, a90098d https://github.com/makinacorpus/django-leaflet/commit/a90098d7dcdbbcdfed329300d568c9691da21860

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/makinacorpus/django-leaflet/issues/188#issuecomment-636440972, or unsubscribe https://github.com/notifications/unsubscribe-auth/AML2Z3BAPSBLTFPMJ6KNEILRUIKADANCNFSM4DJXOK5Q .

faprietoml commented 3 years ago

No solutions for this issue?

faaizajaz commented 3 years ago

No solutions for this issue?

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

faprietoml commented 3 years ago

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 commented 3 years ago

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

faaizajaz commented 3 years ago

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

I based my patch on this PR: https://github.com/makinacorpus/django-leaflet/commit/a90098d7dcdbbcdfed329300d568c9691da21860

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 commented 3 years ago

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.