             popover.removeFromParentViewController()
         }
         selectedArticlePopover = nil
+        selectedArticleAnnotationView = nil
     }
     
     func articlePopoverViewController(articlePopoverViewController: ArticlePopoverViewController, didSelectAction action: WMFArticleAction) {

        var x = annotationCenter.x > viewCenter.x ? viewSize.width - popoverSize.width - spacing : spacing
        var y = annotationCenter.y > viewCenter.y ? viewSize.height - popoverSize.height - spacing : spacing

        let fitsTopOrBottom = (top < 0 || bottom < 0) && viewSize.width - annotationCenter.x > 0.5*popoverSize.width && annotationCenter.x > 0.5*popoverSize.width
        
        let fitsLeftOrRight = (left < 0 || right < 0) && viewSize.height - annotationCenter.y > 0.5*popoverSize.height && annotationCenter.y > 0.5*popoverSize.width
        
        if (fitsTopOrBottom) {
            x = annotationCenter.x - 0.5 * popoverSize.width
            y = annotationCenter.y + (top < bottom ? 0 - totalHeight : popoverDistanceFromAnnotationCenterY)
        } else if (fitsLeftOrRight) {
            x = annotationCenter.x + (left < right ? 0 - totalWidth : popoverDistanceFromAnnotationCenterX)
            y = annotationCenter.y - 0.5 * popoverSize.height
        } else if (top < 0) {
            y = annotationCenter.y - totalHeight
        } else if (bottom < 0) {
            y = annotationCenter.y + popoverDistanceFromAnnotationCenterY
        } else if (left < 0) {
            x = annotationCenter.x - totalWidth
        } else if (right < 0) {
            x = annotationCenter.x + popoverDistanceFromAnnotationCenterX
        }
        
        articleVC.view.frame = CGRect(origin: CGPoint(x: x, y: y), size: popoverSize)
    }
    

    private var currentGroupingPrecision: QuadKeyPrecision = 1
    private let searchHistoryGroup = "PlaceSearch"
    private var selectedArticlePopover: ArticlePopoverViewController?
    private var selectedArticleAnnotationView: MKAnnotationView?
    private var selectedArticleKey: String?
    private var placeToSelect: ArticlePlace?
    private var articleKeyToSelect: String?
