Optimizing OpenLayers. Speed up markers load time!

Icons in OpenLayers!

They chain of classes used to construct and make one single marker in OpenLayers is a bit difficult to follow, but isn’t impossible. There are three main classes in three files:

Markers.js
Layer/Markers.js
Icon.js

That’s why after tracking the code in them I noticed the library’s using appendChild in a line like that:

this.div.appendChild(markerImg);

The problem is that if you’ve a loop with probably hundreds of iterations this is really slow. What I intent to do is to return only the generated code as string, or instead of returning the element, I can return the string. Than concatenate it after the loop’s over.

That will be way faster!

3 thoughts on “Optimizing OpenLayers. Speed up markers load time!

  1. I have the same problem with my site when the number of markers are more than 300. Could you please give me a your implement

  2. Hi John,

    Actually I managed to change the entire markup produced by the markers. In my case they are A tags inside DIV, and the problem was I only needed to get the pixel location from the OpenLayers without DOM generation and so on.

    The solution was pretty simple. It does not change OL at all. Please write me on popov AT stoimen DOT com and I’ll be glad to help.

    regards,
    stoimen

Leave a Reply

Your email address will not be published. Required fields are marked *