خرید بک لینک

Vote count: 0

I'm trying to create a heatmap using Google's API, but ruing into a few issues. The main issue I have run into so far is converting a large set of about ~25000 addresses into geocoordinates for use in the API. The two approaches I have used are Google's own API, which has heavy limitations, and Python's Geopy module, which also has limitations. Since I am trying to convert ~25000, Geopy's one second delay is a pretty steep issue.

The second issue I can see coming is a size limitation. Once I have a list of ~25000 geocoordinates, putting those into an array in Javascript seems ridiculous. Assuming a user would upload a text file in a format like this:

12.3456,-12.3456
23.4567,-23.4567
...

Would there be a way to process the file in blocks, or some other work around?

In case it helps, this is my current Javascript code for processing a file of addresses. I'm plaing on changing the file reading format to find a better system.

var map, heatmap, geocoder;
var MVCarr;

function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: 36.85, lng: -75.97},
        zoom: 7
    });

    MVCarr = new google.maps.MVCArray();
    heatmap = new google.maps.visualization.HeatmapLayer({
        data: MVCarr,
        map: map
    })
}

window.onload = function() {
    var fileInput = document.getElementById('fileInput');
    var fileDisplayArea = document.getElementById('fileDisplayArea');
    geocoder = new google.maps.Geocoder();

    fileInput.addEventListener('change', function(e) {
        var file = fileInput.files[0];

        var reader = new FileReader();

        reader.onload = function(e) {
            var mySplit = (reader.result).split("n");
            for(var i = 0, len = mySplit.length; i < len; i++) {
                //console.log(mySplit[i]);
                geocodeAddress(geocoder, mySplit[i]);
            }
        }
        reader.readAsText(file);
    });
}

function geocodeAddress(geocoder, address) {
    geocoder.geocode({'address': address}, function(results, status) {
        if (status === google.maps.GeocoderStatus.OK) {
            MVCarr.push(results[0].geometry.location);
            console.log(MVCarr.length);
        } else {
            console.log('Failed: ' + status);
        }
    });
}

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 25 ارديبهشت 1395 ساعت: 1:16

صفحه بندی