Do not assume map.getView returns an ol.View2D

This commit is contained in:
Éric Lemoine
2013-04-08 12:55:00 +02:00
parent 8c9153ffca
commit fb5ca531d0
+5 -5
View File
@@ -106,7 +106,7 @@ ol.control.ZoomSlider.CSS_CLASS_THUMB =
ol.control.ZoomSlider.prototype.setMap = function(map) { ol.control.ZoomSlider.prototype.setMap = function(map) {
goog.base(this, 'setMap', map); goog.base(this, 'setMap', map);
this.initSlider_(); this.initSlider_();
var resolution = map.getView().getResolution(); var resolution = map.getView().getView2D().getResolution();
if (goog.isDef(resolution)) { if (goog.isDef(resolution)) {
this.currentResolution_ = resolution; this.currentResolution_ = resolution;
this.positionThumbForResolution_(resolution); this.positionThumbForResolution_(resolution);
@@ -221,7 +221,7 @@ ol.control.ZoomSlider.prototype.amountDragged_ = function(e) {
ol.control.ZoomSlider.prototype.resolutionForAmount_ = function(amount) { ol.control.ZoomSlider.prototype.resolutionForAmount_ = function(amount) {
// FIXME do we really need this affine transform? // FIXME do we really need this affine transform?
amount = (goog.math.clamp(amount, 0, 1) - 1) * -1; amount = (goog.math.clamp(amount, 0, 1) - 1) * -1;
var fn = this.getMap().getView().getResolutionForValueFunction(); var fn = this.getMap().getView().getView2D().getResolutionForValueFunction();
return fn(amount); return fn(amount);
}; };
@@ -235,7 +235,7 @@ ol.control.ZoomSlider.prototype.resolutionForAmount_ = function(amount) {
* @private * @private
*/ */
ol.control.ZoomSlider.prototype.amountForResolution_ = function(res) { ol.control.ZoomSlider.prototype.amountForResolution_ = function(res) {
var fn = this.getMap().getView().getValueForResolutionFunction(); var fn = this.getMap().getView().getView2D().getValueForResolutionFunction();
var value = fn(res); var value = fn(res);
// FIXME do we really need this affine transform? // FIXME do we really need this affine transform?
return (value - 1) * -1; return (value - 1) * -1;
@@ -257,10 +257,10 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) {
if (e.type === goog.fx.Dragger.EventType.DRAG) { if (e.type === goog.fx.Dragger.EventType.DRAG) {
if (res !== this.currentResolution_) { if (res !== this.currentResolution_) {
this.currentResolution_ = res; this.currentResolution_ = res;
map.getView().zoomWithoutConstraints(map, res); map.getView().getView2D().zoomWithoutConstraints(map, res);
} }
} else { } else {
map.getView().zoom(map, this.currentResolution_, undefined, map.getView().getView2D().zoom(map, this.currentResolution_, undefined,
ol.control.ZOOMSLIDER_ANIMATION_DURATION); ol.control.ZOOMSLIDER_ANIMATION_DURATION);
} }
}; };