 
                 // 没有地图图片文件，只能生成了
 
-                let messageID = message.messageID
-
                 let options = MKMapSnapshotOptions()
                 options.scale = UIScreen.mainScreen().scale
                 options.size = size


                        UIGraphicsEndImageContext()

                        let mapImage = finalImage.bubbleImageWithTailDirection(tailDirection, size: size)

                        // save it

                        if let data = UIImageJPEGRepresentation(mapImage, 1.0) {

                            let fileName = NSUUID().UUIDString

                            if let fileURL = NSFileManager.saveMessageImageData(data, withName: fileName) {
                                dispatch_async(dispatch_get_main_queue()) {
                                    let realm = Realm()
                                    if let message = messageWithMessageID(messageID, inRealm: realm) {
                                        realm.write {
                                            message.localAttachmentName = fileName
                                        }

                            }
                        }

                        let mapImage = finalImage.bubbleImageWithTailDirection(tailDirection, size: size)

                        self.cache.setObject(mapImage, forKey: imageKey)

                        dispatch_async(dispatch_get_main_queue()) {
