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

Error reading arraybuffer #22

Open
turbobuilt opened this issue May 6, 2015 · 6 comments
Open

Error reading arraybuffer #22

turbobuilt opened this issue May 6, 2015 · 6 comments

Comments

@turbobuilt
Copy link

Hello, I'm having an issue loading a raw arraybuffer into the shapefile program. Here is the error I get in chrome:

GET http://domain.com/dir/rawinflate.min.js.map 404 (Not Found)
[object%20ArrayBuffer].shp:1 GET http://domain.com/dir/[object%20ArrayBuffer].shp 404 (Not Found)
[object%20ArrayBuffer].prj:1 GET http://domain.com/dir//[object%20ArrayBuffer].prj 404 (Not Found)
[object%20ArrayBuffer].dbf:1 GET http://domain.com/dir//[object%20ArrayBuffer].dbf 404 (Not Found)

The plugin is working fine if I load from a url, but I'm just having an issue here. To load it, I use

var r = new FileReader();
r.onload = function (e) {
  var contents = e.target.result;
  var layer = new L.Shapefile(contents, {style: {
    "color": "#000000",
    "fill": "none",
    "weight": 2
  }});
}
r.readAsArrayBuffer(f)

This may very well be an issue on my end, and if so, sorry for opening an issue.

@calvinmetcalf
Copy link
Owner

I believe you need to do

var contents = r.result;

That's how I've done it at http://leaflet.calvinmetcalf.com

@turbobuilt
Copy link
Author

I changed it to r.result, and got the same error. Using the Javascript debugger in chrome indicates that it is indeed an array buffer that I am passing in both instances. What's more, the same shape file loads fine via AJAX. Any ideas?

@calvinmetcalf
Copy link
Owner

Hm I can look into it tommorow

On Sun, May 10, 2015, 4:12 PM dtruel [email protected] wrote:

I changed it to r.result, and got the same error. Using the Javascript
debugger in chrome indicates that it is indeed an array buffer that I am
passing in both instances. What's more, the same shape file loads fine via
AJAX. Any ideas?


Reply to this email directly or view it on GitHub
#22 (comment)
.

@calvinmetcalf
Copy link
Owner

oo make sure you are not using a worker (aka make sure catiline is not on the page) as that will assume it's a url.

@turbobuilt
Copy link
Author

Awesome, that fixed it! I never would have guessed that myself as I'm not familiar with workers/catiline. Thanks a million!

@davidlukerice
Copy link
Contributor

Are there any plans for supporting passing arrayBuffers to the worker?

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

3 participants