Hi,
in OpenLayers 2.9, you can instantiate the ScaleLine control with the geodesic
option set to true:
new OpenLayers.Control.ScaleLine({
geodesic: true;
});
This will give you an accurate scale line for the current map viewport.
Regards,
Andreas.
On Apr 28, 2010, at 13:33 , Jan wrote:
> Hi all,
> It seems that in lon/lat projections (e.g. EPSG 4326) the scale line is right
> only for the Equator (0 lat).
> If you look at the map, e.g.:
> http://dev.openlayers.org/addins/scalebar/trunk/examples/scalebar.html the
> scaleline stays constant even if you pan map from N to S. It seems that
> Poland for example has a width of 1000 km (W-E), while in fact it has approx.
> 600 km. This is just wrong and for "spatially-unaware" users it will give
> wrong information.
>
> AFAIK scale bar's width can be adjusted using:
>
> OpenLayers.INCHES_PER_UNIT["degrees"] = x;
>
> where x can be calculated using the length of a given parallel (in inches)
> divided by 360 degrees. The default inch per unit value is 4374754.
> 4374754 * 360 degrees = 1574911440 inches = 40000 km (the length of the
> Equator).
>
> It would be nice to implement a default functionality in OL for automatic
> adjustments of INCHES_PER_UNIT value based e.g. on the latitude of a map
> center (for example using moveend or zoomend map events). In this way, the
> scale bar would be always correct at least in the center of the map. If you
> create a map for higher latitudes it is crucial. The wrong scale line I would
> call even a bug (imagine using this scaleline in northern Canada or Norway).
>
> By the way, it seems that Google Maps uses this method to correct the scale
> line (check http://maps.google.com, pan the map in N/S direction and see how
> the scale line adjusts without changing the scale of the map).
>
> Best regards to all OL users,
> Jan
> _______________________________________________
> Users mailing list
> [email protected]
> http://openlayers.org/mailman/listinfo/users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users