Removing stub method, and use the real method in Popup.
This commit is contained in:
@@ -492,16 +492,6 @@ ol.Map.prototype.zoomOut = function() {
|
||||
this.setZoom(this.zoom_-1);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Point} loc the location being requested
|
||||
* @returns {Array} the position of the location in pixel space
|
||||
*/
|
||||
ol.Map.prototype.getViewportPosition = function(loc) {
|
||||
//TODO: delegate this to the renderers
|
||||
//stub for now to get popups working
|
||||
return [200, 300];
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Element} the map overlay element
|
||||
*/
|
||||
|
||||
@@ -162,7 +162,7 @@ ol.Popup.prototype.generateContent_ = function() {
|
||||
return this.template_; //stub to return something
|
||||
} else {
|
||||
ol.error('ol.Popup unabale to generate any content');
|
||||
return '<p>no content</p>'
|
||||
return '<p>no content</p>';
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -243,8 +243,8 @@ ol.Popup.prototype.setAnchorOffset_ = function() {
|
||||
} else {
|
||||
this.pos_ = new ol.geom.Point(this.anchor_.getX(), this.anchor_.getY());
|
||||
}
|
||||
|
||||
var popupPosPx = this.map_.getViewportPosition(this.pos_);
|
||||
var pos = /** @type {ol.Loc} */ (this.pos_);
|
||||
var popupPosPx = this.map_.getPixelForLoc(pos);
|
||||
var popupSize = goog.style.getSize(this.container_);
|
||||
|
||||
switch(this.placement_) {
|
||||
@@ -272,7 +272,7 @@ ol.Popup.prototype.setAnchorOffset_ = function() {
|
||||
popupPosPx[0] += this.arrowOffset_;
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
this.moveTo_(popupPosPx);
|
||||
|
||||
};
|
||||
|
||||
@@ -90,11 +90,25 @@ ol.renderer.MapRenderer.prototype.getLocForPixel = function(pixel) {
|
||||
resolution = this.renderedResolution_,
|
||||
size = goog.style.getSize(this.container_);
|
||||
return new ol.Loc(
|
||||
center.getX() - (size.width/2 - pixel.x) * resolution,
|
||||
center.getY() + (size.height/2 - pixel.y) * resolution
|
||||
center.getX() - (size.width/2 - pixel.x)*resolution,
|
||||
center.getY() + (size.height/2 - pixel.y)*resolution
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ol.Loc} loc
|
||||
* @return {{x: number, y: number}}
|
||||
*/
|
||||
ol.renderer.MapRenderer.prototype.getPixelForLoc = function(loc) {
|
||||
var center = this.renderedCenter_,
|
||||
resolution = this.renderedResolution_,
|
||||
size = this.getSize();
|
||||
return {
|
||||
x: (size.width*resolution/2 + loc.getX() - center.getX())/resolution,
|
||||
y: (size.height*resolution/2 - loc.getY() + center.getY())/resolution
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {goog.math.Size} The currently rendered map size in pixels.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user