[OpenLayers-Users] How to add many(>400) markers to the map?

Christopher Schmidt crschmidt at metacarta.com
Tue Apr 14 10:54:09 EDT 2009


On Tue, Apr 14, 2009 at 10:09:43AM -0300, Chris Adams wrote:
> I don't think a lot of experimentation is required, I would implement it 
> as such:
> 
> g = [view port width / cell size][view port height / cell size]
> 
> For each point, p:
>    px <- convert p to view port PX
>    px <- floor(px / cell size)
>    if px in g is valid and g[px.x][px.y] not defined:
>      g[px.x][px.y] <- p
>  
> for each cell in g, if defined:
>     render g[x][y] as marker
> 
> I'd run this on zoom end, and move end (after pan completes, or after 
> mouse button released)
> 
> The only configuration is the cell size, where 1 would mean there would 
> be at most 1 marker for a given pixel, and the values increase from 
> there. A higher value would mean better preformance, a lower would have 
> a higher density of points.

This is basically how the clustering strategy works.

-- Chris

> - Chris
> 
> altserg at yahoo.com wrote:
> > I think the proper solution would be to limit number of markers depending on zoom level and visible map region. If you're at high zoom level and markers are too close to each other, they will overlap and you do not really see anything. Solution is to render not all markers but skip markers if distance between them is too close (probably distance should be determined by experimenting). When user zooms in, app should communicate with server and request more markers for visible region. 
> >
> > opengts tracking system has the very same problem. I was going to implement something like I explained above myself but it's quite low on my priority list. But if you have the solution, I'd like to use it ;)
> >
> > Serg
> >
> >
> >
> > ----- Original Message ----
> >   
> >> From: willson <talentp1982 at yahoo.com.cn>
> >> To: users at openlayers.org
> >> Sent: Tuesday, April 14, 2009 12:26:40 PM
> >> Subject: Re: [OpenLayers-Users] How to add many(>400) markers to the map?
> >>
> >>
> >>
> >>
> >> Hi,
> >> if you were using Geoserver and wms, dynamic symbolizer could help you. 
> >> Check the following out:
> >>
> >> http://blog.geoserver.org/2008/12/08/dynamic-symbolizers-part-1/
> >>
> >> - mika -
> >>
> >>
> >> willson kirjoitti:
> >>     
> >>> Hi,
> >>> try to search mailing list for strategies, performance. I have the same 
> >>>       
> >> problem not solved yet. It looks I will have to render at server site.
> >>     
> >>> Michal
> >>>
> >>>
> >>> Hi everyone, this is the first post on this forum. I have search the problem 
> >>>       
> >> on the forum, but find no anwser.
> >>     
> >>> What I need to solve is:  I have more than 400 points need to show on the map, 
> >>>       
> >> these points query my db every 10 secs, and change their color according to the 
> >> return value. 
> >>     
> >>> I use the openlayers.layer.marker to implement, but in ie the markers make the 
> >>>       
> >> map so slow when zooming.
> >>     
> >>> Then I move to  openlayers.layer.vector, but it's even slower than marker.
> >>> Any suggestion in such "Adding large and dynamically changed markers"  
> >>>       
> >> situation?
> >>     
> >>>
> >>>
> >>> hi, render in serverside(may be wms) can improve the performance much, but how 
> >>>       
> >> to make markers dynamically change color? Any solution?
> >>     
> >>>  
> >>>       
> >> _______________________________________________
> >> Users mailing list
> >> Users at openlayers.org
> >> http://openlayers.org/mailman/listinfo/users
> >>
> >>
> >>
> >> hi,
> >> Yes, I am using geoserver and wms. I have look at the link, but it may be not 
> >> the answer. Since the data in my db change frequently,  and the marker need to 
> >> reflect these changes. For example , I have a table, and a column named "kpi", 
> >> when kpi<0.01, the marker's color is green, else is red. It may be not an "sld" 
> >> issue.
> >>
> >> -- 
> >> View this message in context: 
> >> http://n2.nabble.com/How-to-add-many%28%3E400%29-markers-to-the-map--tp2631715p2632376.html
> >> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users at openlayers.org
> >> http://openlayers.org/mailman/listinfo/users
> >>     
> >
> >
> >
> >       
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> >
> >   
> 
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list