openlayers中的弹出窗口

openlayers中的弹出窗口,openlayers,Openlayers,弹出窗口和框架与框架之间的区别是什么 而且,弹出窗口的方向似乎取决于标记相对于地图的位置。pop可能在标记上方或下方 例如: 以上: 下: 现在,我想知道如何使弹出窗口始终位于标记的上方?好吧,我自己回答这个问题 您可以覆盖FramedCloud的calculateRelativePosition函数,如下所示: OpenLayers.FramedCloud.prototype.calculateRelativePosition=function(){ return 'tr'; } 此

弹出窗口和框架与框架之间的区别是什么

而且,弹出窗口的方向似乎取决于标记相对于地图的位置。pop可能在标记上方或下方

例如:

以上:

下:


现在,我想知道如何使弹出窗口始终位于标记的上方?

好吧,我自己回答这个问题

您可以覆盖FramedCloud的
calculateRelativePosition
函数,如下所示:

OpenLayers.FramedCloud.prototype.calculateRelativePosition=function(){
  return 'tr';
}
此函数继承自
OpenLayers.Popup.archored

计算位置:函数(px){

},

var lonlat = this.map.getLonLatFromLayerPx(px);

var extent = this.map.getExtent();
var quadrant = extent.determineQuadrant(lonlat);

return OpenLayers.Bounds.oppositeQuadrant(quadrant);