i want to use FSInteractiveMap in swift but documentations are only is Objective-C and i can't Translate click Handler in swift.
NSDictionary* data = @{ @"asia" : @12,
@"australia" : @2,
@"north_america" : @5,
@"south_america" : @14,
@"africa" : @5,
@"europe" : @20
};
FSInteractiveMapView* map = [[FSInteractiveMapView alloc] initWithFrame:self.view.frame];
[map loadMap:@"world-continents-low" withData:data colorAxis:@[[UIColor lightGrayColor], [UIColor darkGrayColor]]];
in swift working with:
let map: FSInteractiveMapView = FSInteractiveMapView()
map.frame = self.view.frame
var mapData = [String: Int]()
mapData["IR-01"] = 0
mapData["IR-02"] = 10
var mapColors = [UIColor]()
mapColors.append(UIColor(red:0.26, green:0.112, blue:0.0, alpha:1.0))
mapColors.append(UIColor(red:0.45, green:0.132, blue:0.0, alpha:1.0))
map.loadMap("iranHigh", withData:mapData, colorAxis:mapColors)
view.addSubview(map)
view.setNeedsDisplay()
its working correctly but i cant add click Handler
here is documentation in Objective-C:
FSInteractiveMapView* map = [[FSInteractiveMapView alloc] initWithFrame:CGRectMake(16, 96, self.view.frame.size.width - 32, 500)];
[map loadMap:@"usa-low" withColors:nil];
[map setClickHandler:^(NSString* identifier, CAShapeLayer* layer) {
if(_oldClickedLayer) {
_oldClickedLayer.zPosition = 0;
_oldClickedLayer.shadowOpacity = 0;
}
_oldClickedLayer = layer;
// We set a simple effect on the layer clicked to highlight it
layer.zPosition = 10;
layer.shadowOpacity = 0.5;
layer.shadowColor = [UIColor blackColor].CGColor;
layer.shadowRadius = 5;
layer.shadowOffset = CGSizeMake(0, 0);
}];
OR:
[map setClickHandler:^(NSString* identifier, CAShapeLayer* layer) {
self.detailDescriptionLabel.text = [NSString stringWithFormat:@"Continent clicked: %@", identifier];}];
how can i do it in Swift?