1
votes

Is there a limit to the number of kml files which can be rendered? I know there is a file size limit but I seem to be hitting another limit.

The error thrown is

GET https://mts1.googleapis.com/mapslt?hl=en-US&lyrs=kml%3AcXOw0bjKUSgN5kcEMpDT…7Capi%3A3%7Cclient%3A2&x=67&y=98&z=8&w=256&h=256&source=apiv3&token=127990 414 (Request-URI Too Large) mts1.googleapis.com/mapslt?hl=en-US&lyrs=kml%3AcXOw0bjKUSgN5kcEMpDTUkENzfIp…api%3A3%7Cclient%3A2&x=67&y=98&z=8&w=256&h=256&source=apiv3&token=127990:1

Below is an example of what I am attempting to accomplish.

http://tinyurl.com/qg5enx8

2
Seems to work after the map is initialized. American Samoa's URL doesn't seem to work, unless the space is removed.Sunny Patel
I fixed that entry. But it still doesnt work, I receive errors on all the kml files.user3032973

2 Answers

1
votes

from the documentation

There is a limit on the number of KML Layers that can be displayed on a single Google Map. If you exceed this limit, none of your layers will display. The limit is based on the total length of all URLs passed to the KMLLayer class, and consequently will vary by application; on average, you should be able to load between 10 and 20 layers without hitting the limit.

1
votes

Try using Network links: https://developers.google.com/kml/documentation/kml_tut?csw=1#network_links

I know it sounds a but more cumbersome, but it helps when loading lots of KML Data at once.

Another option is to change your approach and use Google Fusion Tables through the Javascript API. Basically to start on this route, you'll need to load the script: https://apis.google.com/js/client.js?onload=init where onload refers to YOUR javascript function to run once the script is loaded. Mine looks something like this:

function init() {
    gapi.client.load('fusiontables', 'v1', function() {
        gapi.client.setApiKey( YOUR_API_KEY_AS_STRING );
        gapi.client.fusiontables.query.sql({sql:["SELECT * FROM", TABLE_NAME].join(' '), fields:'rows, columns'}).execute( function(json) {
            //Do what you need to parse the json response
            //Set up KML Layers
            //etc... make sure to check if maps is loaded too
            json.rows.forEach( function(t) {
                console.log( t );
            });
        });
    });
}