         
         
         
-//        
-//        SocketConn.openStreamAndSendValues(flagDirectionX, flagY: flagDirectionY, speed: speed, direction: angle)
+        //
+        //        SocketConn.openStreamAndSendValues(flagDirectionX, flagY: flagDirectionY, speed: speed, direction: angle)
     }
     
+    @IBAction func createMapBtn(sender: AnyObject) {
+        let mapSize = CGSize(width: mapView.bounds.width, height: mapView.bounds.height)
+        let map = drawMap(mapSize)
+        mapView.image = map
+    }
+    func drawMap(size: CGSize) -> UIImage{
         let bounds = CGRect(origin: CGPoint.zero, size: size)
         let opaque = false;
         let scale : CGFloat = 0;

    var green: CGFloat = 0.0
    var blue: CGFloat = 0.0
    var timer = NSTimer()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        self.SocketConn = SocketConnection()
        
       
        
        
        //
        //        var timer = NSTimer.scheduledTimerWithTimeInterval(0.05, target: self, selector: Selector("updateJoystickCoordinates:"), userInfo: nil, repeats: true)
        
        self.timer = NSTimer.scheduledTimerWithTimeInterval(0.05, target: SocketConn!, selector: Selector("sendValue:"), userInfo: joystick, repeats: true)
        // Do any additional setup after loading the view, typically from a nib.
        
    }
    
    override func viewDidDisappear(animated: Bool) {
        print("view disappeared")
        self.SocketConn!.closeStream()
        self.timer.invalidate()
    }
    
    override func didReceiveMemoryWarning() {
