Pregunta

My client works only with IE8. He has openlayers map that he want to load 3000 polygons on it. Chrome and IE9 can do this easily, but IE8 freeze. Objects come from web service as json xml , being parsed and added to vector layer. IE8 throws an exception while add the objects:

"Stop running this script? A script on this page is causing Internet Explorer to run slowly ..."

I've tried to load features as multithreading, but this is too slow.

Any Ideas?

¿Fue útil?

Solución

what I expect you did was taking the whole bunch of features, call a loop for each and add them to the vector layer such as:

for(var feat in feats) {
   vectorLayer.add(feats[feat]);
}

maybe give it a try with a recursive function. I haven't got IE8 to test it but it might help. also you can use a small timeout on calling that recursive function (1 ms or so), so it will take 3 secs. to load 3000 of them, but you can monitor the counting and everything in the background, so you will be able to put a progress bar in your page, so it won't be hurting the user so much. but first try without timeout if it gets any better. e.g.

//global
var features;

function processFeatures()  {
   if (features[0] != null ) {
      vectorLayer.add(features[0]); //add the (first) feature to the vector layer
      features.splice(0,1); //remove the last added feature from the source
      processFeatures(); // or put setTimeout(processFeatures,1);
   }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top