Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 2 working example. #7

Open
mmmattos opened this issue Mar 19, 2016 · 5 comments
Open

Swift 2 working example. #7

mmmattos opened this issue Mar 19, 2016 · 5 comments

Comments

@mmmattos
Copy link

Hello

I am trying to use FSInteractiveMap inside a Swift iOS app.

I followed the How to use Section in the github repo

Added the library through the pod file.
The app builds fine but nothing gets displayed.

I debugged to check if the svg was loaded and indeed it was.
Here is the code I put in the swift file code:

import UIKit
import FSInteractiveMap

class ViewController: UIViewController {

    override func viewDidLoad() {
        let map: FSInteractiveMapView = FSInteractiveMapView()

        var mapData = [String: Int]()
        mapData["asia"] = 12
        mapData["australia"] = 2
        mapData["north_america"] = 5
        mapData["south_america"] = 14
        mapData["africa"] = 5
        mapData["europe"] = 20

        var mapColors = [UIColor]()
        mapColors.append(UIColor.lightGrayColor())
        mapColors.append(UIColor.darkGrayColor())

        let mapName: String! = String("world-continents-low")
        map.loadMap(mapName, withData:mapData, colorAxis:mapColors)

        view.addSubview(map)
        view.setNeedsDisplay()
         super.viewDidLoad()        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

I appreciate if you can point to any working swift example using it or identify what is wrong in this code.
Best!

@TheGeekPharaoh
Copy link

Curious if you've managed to get this working. I'm experiencing similar issues in Swift, particularly when trying to put my FSInteractiveMapView inside a UIStackView

@mmmattos
Copy link
Author

No, unfortunately not.
Still trying to get something similar on swift. Now attempting with D3 maps.

Miguel Miranda de Mattos | entrepreneur | software | mobile/web/cloud
|
Miranda Mattos Inf. Ltda. | Porto Alegre/RS | m. (51) 9198.9914
skype/miguelmmattos | face/miguel.mattos | linkedin/miguelmmattos

On Mon, Apr 11, 2016 at 5:08 PM, sdnakhla [email protected] wrote:

Curious if you've managed to get this working. I'm experiencing similar
issues in Swift, particularly when trying to put my FSInteractiveMapView
inside a UIStackView


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#7 (comment)

@ArnaudRib
Copy link

ArnaudRib commented Nov 17, 2016

I believe you are missing to define a frame for your map.

Writing :

map.frame = self.view.frame

right below

let mapName: String! = String("world-continents-low")
map.loadMap(mapName, withData:mapData, colorAxis:mapColors)

should make it work.

@mmmattos
Copy link
Author

Thanks @ArnaudRib 😄
I'll try that later today and let you know if that works fine.
Hope it does work on swift 3 too.

@ArnaudRib
Copy link

ArnaudRib commented Nov 17, 2016

@mmmattos
The syntax for frame has not changed in Swift 3.0, so this little code should still be working :).

Did you manage to make the clickHandler work ? I still can't figure out how to use the function properly in swift.

Have a good day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants