         return nil
     }
     
+    override func setSelected(_ selected: Bool, animated: Bool) {
+        super.setSelected(selected, animated: animated)
+        if selected {
+            dotView.alpha = 1
+            imageView.alpha = 0
+            imageView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
+        } else {
+            imageView.alpha = 1
+            dotView.alpha = 0
+        }
+        let animations = {
+            if selected {
+                self.imageView.alpha = 1
+                self.imageView.transform = CGAffineTransform.identity
+                self.dotView.alpha = 0
+            } else {
+                self.dotView.alpha = 1
+                self.imageView.alpha = 0
+                //self.imageView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
+            }
+        }
+        if (animated) {
+            UIView.animate(withDuration: 0.2, animations: animations, completion: nil)
+        } else {
+            animations()
+        }
+    }
+    
     override func layoutSubviews() {
         super.layoutSubviews()
+        imageView.frame = bounds
+        imageView.layer.cornerRadius = imageView.bounds.size.width * 0.5
         if countLabel.text != nil {
-            imageView.bounds = CGRect(x: 0, y: 0, width: groupDimension, height: groupDimension)
-            imageView.center = CGPoint(x: 0.5*bounds.size.width, y: 0.5*bounds.size.height)
-        } else if isSelected {
-            imageView.frame = bounds
+            dotView.bounds = CGRect(x: 0, y: 0, width: groupDimension, height: groupDimension)
+            dotView.center = CGPoint(x: 0.5*bounds.size.width, y: 0.5*bounds.size.height)
         } else {
-            imageView.bounds = CGRect(x: 0, y: 0, width: collapsedDimension, height: collapsedDimension)
-            imageView.center = CGPoint(x: 0.5*bounds.size.width, y: 0.5*bounds.size.height)
+            dotView.bounds = CGRect(x: 0, y: 0, width: collapsedDimension, height: collapsedDimension)
+            dotView.center = CGPoint(x: 0.5*bounds.size.width, y: 0.5*bounds.size.height)
         }
-        imageView.layer.cornerRadius = imageView.bounds.size.width * 0.5
+        dotView.layer.cornerRadius = dotView.bounds.size.width * 0.5
         countLabel.frame = imageView.frame
     }
 }

    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
        imageView = UIImageView()
        countLabel = UILabel()
        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
        
        let dimension = 50
        frame = CGRect(x: 0, y: 0, width: dimension, height: dimension)
        
        imageView.contentMode = .scaleAspectFill
        imageView.layer.borderWidth = 2
        imageView.layer.borderColor = UIColor.white.cgColor

    func update() {
        if let articlePlace = annotation as? ArticlePlace {
            if articlePlace.articles.count == 1 {
                dotView.backgroundColor = UIColor.wmf_green()
                let article = articlePlace.articles[0]
                if let thumbnailURL = article.thumbnailURL {
                    imageView.backgroundColor = UIColor.white
                    imageView.wmf_setImage(with: thumbnailURL, detectFaces: true, onGPU: true, failure: { (error) in
                         self.imageView.backgroundColor = UIColor.wmf_green()
                    }, success: {
                        
                    })
                } else {
                    imageView.image = nil
                    imageView.backgroundColor = UIColor.wmf_green()
                }
            } else {
                dotView.backgroundColor = UIColor.wmf_green().withAlphaComponent(0.7)
                countLabel.text = "\(articlePlace.articles.count)"
            }
        }
