fixed a bug calculating wrong rectangle if viewport overlaps map borders