Current marker distance to map bounds
===

i need the current distance between the marker and the map bounds to decide: draw the tipbox left, right, over or under the marker.

I set the position of the tipbox with these lines of code:

    Label.prototype.draw = function() {
      var projection = this.getProjection();
      var position = projection.fromLatLngToDivPixel(this.get('position'));
				
      // position of tipbox, depends on margin to map boaunds
      var div = this.div_;
      var mapWidth = parseInt($('#mapBox').css('width'));
      var mapHeight = parseInt($('#mapBox').css('height'));
							
      div.style.left = (position.x-(parseInt(div.style.width)/2)) + 'px';
      div.style.top = position.y + 'px';      
      div.style.display = 'inline';

      $('.tipBox-inner').html(''+position.x);
    };	

But if i drag the page, the position.x or position.y return the same number of pixels. As you can see on the image, the x position is at 300px(!). I would draw the tipbox in top of the marker, if the marker is at the bottom of page and so on.

![enter image description here][1]


  [1]: http://i.stack.imgur.com/6yxnI.jpg