简体   繁体   中英

How can I split large json file into multiple small chunk files using javascript to display in google map

I have JSON file of size 200MB.
I want to create a small chunk file and display it in google map ( map.data.loadGeoJson() )
I am getting fileName as comma separated String.

Here's my javascript code:

if (parent.getFileName().length > 0) {
    var fileName = parent.getFileName();
    var fileName_array = fileName.split(',');
    for(var i = 0; i < fileName_array.length; i++) {
        // Trim the excess whitespace.
        fileName_array[i] = fileName_array[i].replace(/^\s*/, "").replace(/\s*$/, "");
        map.data.loadGeoJson(fileName_array[i]);
    }
}

You can use https://pinetools.com/split-files for split data and you can create multiple files from this link then you can use map.data.loadGeoJson(). also please do defer for the script so a browser will not crash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM