Skip to content

Swift 2 working example. #7

@mmmattos

Description

@mmmattos

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions