Hello list,
I created a ticket for this issue: http://trac.geoext.org/ticket/363
Reffering to the mail of Andreas I created a local patch checking wheter
the map has a scale array or the baseLayer has a scale array. If there
are no predefined scales, a calculation with
OpenLayers.Util.getScaleFromResolution(...) will be done.
The code looks like
populateFromMap: function() {
var zooms = [];
var resolutions = this.map.baseLayer.resolutions;
var units = this.map.baseLayer.units;
for (var i=resolutions.length-1; i >= 0; i--) {
var res = resolutions[i];
var scale;
if(this.map.scales && this.map.scales !== 'undefined'){
scale = this.map.scales[i];
}
else if (this.map.baseLayer.scales &&
this.map.baseLayer.scales !== 'undefined') {
scale = this.map.baseLayer.scales[i];
}
else {
scale = OpenLayers.Util.getScaleFromResolution(res, units);
}
zooms.push({
level: i,
resolution: res,
scale: scale
});
}
this.loadData(zooms);
},
Note: If there are only scales provided by baseLayer the scale is wrong
again, instead of 1:50000 1:49999 is displayed, because the baseLayer
object contains the wrong value ([250000.00000000003, 49999.99999999999,
20000, 4 more...]). So it seems to be an OpenLayers problem as well.
Nevertheless in my opinion it would be useful to take the predefined
scales from the objects instead of calculating them again in
GeoExt.data.ScaleStore.
Any comments?
Best regards,
Chris
Am 11.10.2010 10:34, schrieb Andreas Hocevar:
> Hi Chris,
>
> thanks for the patch - this would definitely be good to have in the code
> base, but it needs some work. Can you please create a ticket and add your
> patch? If you don't have a trac account, send me a PM with your desired user
> name and I'll create one for you.
>
> You should add two assertions to the unit tests to show that the scales are
> populated correctly for maps and base layers with and without a scales array.
> You will see that there are several cases to consider, depending on whether
> the scales array was set on the map or on the base layer or on both.
>
> Regards,
> Andreas.
>
> On Oct 11, 2010, at 10:01 , Christian Mayer wrote:
>
>
>> Hello list,
>>
>> within a GeoExt project I used the ScaleStore due to the example at
>> http://api.geoext.org/1.0/examples/zoom-chooser.html.
>> The problem is that some scales are not shown correctly in the scale
>> chooser, for example 1:49999 instead of 1:50000. Some recherche clarified
>> that in the populateFromMap() function in GeoExt.data.ScaleStore the scales
>> are always calculated with OpenLayers.Util.getScaleFromResolution(...),
>> although they are defined in this.map.scales.
>> To fix this problem for my project I modified the ScaleStore.js (see
>> attached patch). Maybe this modification could be interesting for the
>> general GeoExt code base.
>>
>> Thanks for any review.
>>
>> Best regards,
>> Chris
>>
>> <scalestore-get-map-scale.patch>_______________________________________________
>> Dev mailing list
>> [email protected]
>> http://www.geoext.org/cgi-bin/mailman/listinfo/dev
>>
>
>
>
_______________________________________________
Dev mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/dev