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

Converting files back to back returns the same result #20

Open
jeetdas opened this issue Feb 27, 2019 · 3 comments
Open

Converting files back to back returns the same result #20

jeetdas opened this issue Feb 27, 2019 · 3 comments

Comments

@jeetdas
Copy link

jeetdas commented Feb 27, 2019

I was converting multiple zipped shapefiles to geojson and if you call the loadshp multiple times, all of them return the results of the last call. This is really odd and I'm not sure if I'm doing something wrong.

Here is the method:

function loadShapeFile(fileLocation, mymap, L, temp) {
    loadshp({
        url: fileLocation,
        encoding: 'big5' // default utf-8
    }, function(geojson) {
        temp(geojson);
        L.geoJSON(geojson, {
            style: myStyle2
        }).addTo(mymap);
    });
}

and the calls are (The log is just to help debug what is going on):

loadShapeFile('/gis_assets/Conduits.zip', mymap, L, function(geo) {
    console.log(geo);
});

and

loadShapeFile('/gis_assets/Weirs.zip', mymap, L, function(geo) {
    console.log(geo);
});

Because the Weris.zip is the second call, both of them are logging the results of the second call:

screen shot 2019-02-27 at 9 18 09 am

Not sure what is going on, I'm looking into it more but I wasn't sure if others had run into the same problem.

@ClementRb
Copy link

I've got the same problem, it looks like the return of the loadshp function is called two time after converting an other zip file.

@thalesgb
Copy link

thalesgb commented Mar 9, 2020

@ClementRb to solve the problem, you need to clean the variable inputData.
So in the function loadshp just add an inputData= {};

@ClementRb
Copy link

@thalesgb Thanks, it's working properly now.

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