Страница 1 из 1

Openlayers. Вычислить значение масштаба из Extent

Добавлено: 22 апр 2013, 16:36
dooh007
Есть значение Extent из которого нужно вычислить значение масштаба (Scale). Понимаю,что одного Extent мало, нужно учитывать ед.измерения и DPI. Из формул нашел только вот http://trac.osgeo.org/openlayers/wiki/r ... ng_started

Re: Openlayers. Вычислить значение масштаба из Extent

Добавлено: 22 апр 2013, 19:12
dooh007
Вроде сделал сам

//нужный Extent
var positionExtent = new OpenLayers.Bounds(lon1, lat1, lon2, lat2).transform(fromProjection, toProjection);
positiondX = positionExtent.right - positionExtent.left;
positiondY = positionExtent.top - positionExtent.bottom;

//текущий
currentExtent = OpenLayersMap.getExtent();
currentdX = currentExtent.right - currentExtent.left;
currentdY = currentExtent.top - currentExtent.bottom;
currentScale = OpenLayersMap.getScale();

//positionScale = ( positiondX * currentScale ) / currentdX;
positionScale = ( positiondY * currentScale ) / currentdY; //правильно вычисляется черезY