[OpenLayers-Users] OpenLayers.LoadURL for kml file - Unhandled request return found

Tim Schaub tschaub at opengeo.org
Tue May 20 22:35:52 EDT 2008


ashlin wrote:
> Hi,
> 
> I would like to know if there is any limit in the kml file size or http
> request object. I have tried to load a 1.5mb(9000 markers) kml file using
> the methods below. It showed a javascript error popup window "Unhandled
> request return found". However, it works fine when i reduced the kml file
> size to around 59kb (300 markers). What could be the possible problem?

If your server failed to deliver the doc, you'd get the alert mentioned 
above.  Firebug can assist you in exploring XMLHttpRequest request/response.

Even if the request is successful, I doubt you'll please many users 
waiting to parse 9000 markers - much less display them all at once.

Tim

> 
> function load() {
>             OpenLayers.loadURL("kml/doc.kml", "", null, parseData);
>  }
> 
> 
> function parseData(req) {
> 	    
>           g =  new OpenLayers.Format.KML({extractStyles: true});
>           
>           features = g.read(req.responseText);
> 
> 	    var url = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
>             var sz = new OpenLayers.Size(10, 17);
>             var calculateOffset = function(size) {
>                                     return new OpenLayers.Pixel(-(size.w/2),
> -size.h);
>                                  };
> 
>           var icon = new OpenLayers.Icon(url, sz, null, calculateOffset);
>           var countMarkers = 0;    
> 	  var myArray = new Array();
>   
>           for(var feat in features) {
> 		myArray[feat] = new OpenLayers.Marker(new
> OpenLayers.LonLat(features[feat].geometry.x, features[feat].geometry.y),
> icon.clone());
>    		//alert(features[feat].geometry.x);
>    	      
> 		myArray[feat].events.register("click", {'marker':myArray[feat],
> 'testNo':feat},
> 
>                 function (e) {
> 			alert(this.testNo);
> 			onFeatureSelect(features[this.testNo]);
> 			//Event.stop(e);
> 
>                  }     );
> 
> 		kmlLayer.addMarker(myArray[feat]);
> 	  	countMarkers++;
> 
>            }
> 		
> 		alert(countMarkers);
>         }
> 
> 
> ashlin




More information about the Users mailing list