[OpenLayers-Users] OpenLayers Optimization - many vectors
Paw3l
goghi at o2.pl
Fri Apr 23 09:28:09 EDT 2010
Hi,
I am wondering if it is possible to optimize slightly my openlayers
application.
I have about 5000 objects of type Vector (all of which are in fact four
squared polygons). I was building all this list in this way:
<c:forEach var="outer" items="${requestScope.polygons}" >
var polygon = new StringBuffer();
polygon.append("POLYGON(")
<c:forEach var="inner" items="${outer.points}">
polygon.append(${inner.x}+ " " + ${inner.y} + ",")
</c:forEach>
polygon.buffer[polygon.buffer.length - 1] =
polygon.buffer[polygon.buffer.length - 1].substring(0,
polygon.buffer[polygon.buffer.length - 1].length - 1)
polygon.append(")")
var feature = new
OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT(polygon), {name:
'${outer.number}'})
feature.fid = '${outer.id}'
vectors.addFeatures([feature])
</c:forEach>
As I said before there is a pretty large number of these polygons and every
operation takes many seconds (even the dragging the whole draw when I want
to see polygons that are outside of the current view).
I have tried to rewrite my code to use JSON:
OpenLayers.loadURL('http://localhost:8080/swanny/yard/gravesJSON', '', this,
allright, failure)
function allright(req) {
g = new OpenLayers.Format.GeoJSON();
vectors.addFeatures(g.read(req.responseText))
}
but it is even worse :( My openlayers map is loading very slow and every
action on it is very slow too.
Could anyone point me where could I look for some optimization information?
Or maybe someone knows the way I could do it? Google does not answer too
much...
Big thanks,
Pawel
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Optimization-many-vectors-tp4950514p4950514.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list