Take the 2-minute tour ×

I'm using OpenLayers to display OpenStreetMap maps. (Though, I'd assume this should be general enough to work for any map product...)

I'm displaying some very sophisticated vector overlays, and the amount and resolution of the features I'm returning from the server via GeoJSON to overlay has proven too much for many computers.

What I'd like to do now instead is to only send data befitting the resolution of the current zoom. This should be relatively easy to do using the getResolution and calculateBounds methods on the Map object. calculateBounds returns a Bounds object that then can be transformed between the map projection and display projection.

How do I transform the resolution into my desired projection (4326 in this case)? Is there a built in way of doing this or do I have to run the resolution against a known formula?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can use Proj4js to transform coordinate systems on the client.

share|improve this answer
Sweet, I was about to abandon this question. Nice save. –  David Pfeffer Mar 29 '10 at 23:13
And, as you've probably found, OpenLayers has support for Proj4JS (but you need to include it yourself). They make quite a powerful combination. –  winwaed Nov 18 '10 at 20:04

How about just limiting the scale at which your GeoJSON vector layer will draw?


Then the OpenLayers AJAX requests to the server should only trigger beyond this scale. Pick an OpenSteetMaps scale / zoom level that corresponds to when you want to show the vector layer, and set the maxScale accordingly.

The requests should automatically be sending the bounds of the current map display to your server to get the relevant features.

I may have misunderstood your dilemma though. If you want the resolution formulas this article describes them:



You could implement a clustering strategy in OpenLayers. I think this should reduce rendering time, although I'd presume the same amount of data would be returned from the database.


Check out the example here:


To avoid having different sized points you sould set the pointRadius: "${radius}" to a constant.

Finally an alternative would be to use a WMS service rather than GeoJSON, the server would then only be returning images of a fixed size.

share|improve this answer
I'm looking for a latitude/longitude per pixel number. –  David Pfeffer Mar 9 '10 at 16:13
I would like to use something more inbuilt to convert the resolution. For boundaries, I don't do any math, I just call the transform method. Isn't there something similar? Also, you indicate that the layer should be automatically sending its bounds. I don't see how that would happen since it is a standard vector layer. Am I using the wrong sort of layer? A WMS service isn't an option right now for us. –  David Pfeffer Mar 10 '10 at 14:32

Your Answer


