[OpenLayers-Users] Mapping website visitors with OpenLayers?

Christopher Schmidt crschmidt at metacarta.com
Thu Feb 8 12:40:48 EST 2007


On Thu, Feb 08, 2007 at 04:25:47PM +0000, Alexandre Leroux wrote:
> 
> Hi list,
> 
> Thanks to David and Christopher. I was hoping to be able to do it with 
> OpenLayers alone :-)
> 
> I am not familiar with MapServer (or MapGuide or PostGIS, etc). I will 
> not have access to the server, so setting up a webmapping server seems 
> improbable. I'll try finding an easy solution.
> 
> Maybe one day OpenLayers will be able to do this (e.g. mapping huge 
> number of markers and mapping densities)? I hope so ;-)

The problem is not with OpenLayers -- that is, there is nothing specific
that OpenLayers does which makes this slow -- but instead with browsers
themselves.

The thing which is slow is:
 <div id="viewport" style="top:0px; left:0px;">
   <div>Content</div> 
   <div>Content</div> 
   ... repeat 500 or more times 
   <div>Content</div> 
 </div>

Then, in Javascript, do this:

 for(i=0; i < 50; i++) {
   viewport.style.top=(parseInt(viewport.style.top)+1) + "px"; 
 }

I expect that you will find it behaving at a speed that is
non-interactive.

Now realize that OpenLayers does the equivilant of this (though it is
slightly more complex) every time the map moves. The time that is taken
here is not by OpenLayers, but instead by the browser -- each of those
small moves takes a non-zero length of time.

I think you'll find this in any situation. In the Google Maps API a year
ago, I found that anything more than 250 markers will make browsers fall
over. We've gone significantly beyond that, but we can't change the fact
that browsers simply can't perform in the way that we want them to --
instantly, all the time.

So, although Moore's Law will help us as time goes on, the problem is
not one that can be solved with more code -- instead, it is a case that
simply needs to be accomodated for and affects the decisions of how
something is done.

If you really can't do anything serverside, you might look into trying
some client-side clustering, but that seems hairy, and is well beyond
the idea of what I'd want to try :)

Good luck.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list