add the ability to load images using ajax#51
add the ability to load images using ajax#51robertleeplummerjr wants to merge 10 commits intomapbox:gh-pagesfrom
Conversation
…ficiencies found in Chrome and IE
index.js
Outdated
There was a problem hiding this comment.
This should be an else, right? Otherwise this both loads images via URL and loads them with ajax slightly after.
There was a problem hiding this comment.
It is an implied else, with the return; at the bottom of the if statement.
There was a problem hiding this comment.
I corrected the else to me more explicit. Also I fixed a bug that caused onload to be called multiple times depending on latency and I also now cache the images internally to cut down on requests.
use else because it looks better correct onload duplicate callback issue causing images to intermittently show up
|
Is this pr satisfactory? I'd like to get it merged and start on handling canvas layers so that, for example, the points here: http://robertleeplummerjr.github.io/Leaflet.glify/ show up. I plan on adding this today. |
… exists and canvas property exists
|
added canvas layer rendering |
There was a problem hiding this comment.
why is there a settimeout here, and previously?
There was a problem hiding this comment.
It wouldn't work without it. Honestly not sure.
There was a problem hiding this comment.
There is always that chance that it had something to do with the gravitation and alignment of the planets... I'll try it later without it just to make sure.
:P
|
Happy to merge once the setTimeout is deciphered. |
| im.src = cache; | ||
| if (!loaded) { | ||
| setTimeout(function() { | ||
| im.onload(); |
There was a problem hiding this comment.
The image isn't yet added to the page, but is base64. setTimeout(fn, 0) ensures it is loaded when the next available context is, which (since we just set the src) is just after the src is rendered. Otherwise the image is not yet rendered, thus resulting in a blank image.
There was a problem hiding this comment.
Sorry for the tardy response.
# Conflicts: # index.js # leaflet-image.js
# Conflicts: # index.js # leaflet-image.js
Added the ability to use ajax, which can overcome certain security deficiencies found in Chrome and IE.
Overcomes the following obstacle: http://stackoverflow.com/questions/19244006/chrome-basic-auth-image-requests-return-401-but-not-when-called-directly
This is now a browser behaviour, where other browsers are following suite.