Created
January 27, 2015 23:15
-
-
Save davidm49090/bcb26d1b92cdee14daea to your computer and use it in GitHub Desktop.
Rewrite into Swift of https://www.mapbox.com/mapbox-ios-sdk/examples/marker-image-color/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.mapbox.com/mapbox-ios-sdk/examples/marker-image-color/ | |
import UIKit | |
//class ViewController: UIViewController | |
class ViewController: UIViewController, RMMapViewDelegate | |
{ | |
override func viewDidLoad() | |
{ | |
//[super viewDidLoad]; | |
super.viewDidLoad() | |
//[[RMConfiguration configuration] setAccessToken:@"<access token>"]; | |
//RMMapboxSource *tileSource = [[RMMapboxSource alloc] initWithMapID:@"examples.map-z2effxa8"]; | |
var tileSource: RMMapboxSource = RMMapboxSource(mapID: "examples.map-z2effxa8") | |
//RMMapView *mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource]; | |
var mapView: RMMapView = RMMapView(frame: view.bounds, andTilesource: tileSource) | |
//mapView.delegate = self; | |
mapView.delegate = self | |
//[self.view addSubview:mapView]; | |
self.view.addSubview(mapView) | |
//RMAnnotation *annotation = [[RMAnnotation alloc] initWithMapView:mapView coordinate:mapView.centerCoordinate andTitle:@"Bus Stop"]; | |
var annotation: RMPointAnnotation = RMPointAnnotation(mapView: mapView, coordinate: mapView.centerCoordinate, andTitle: "Bus Stop") | |
//[mapView addAnnotation:annotation]; | |
mapView.addAnnotation(annotation) | |
} | |
func mapView(mapView: RMMapView!, layerForAnnotation annotation: RMAnnotation!) -> RMMapLayer! | |
{ | |
if (annotation.isUserLocationAnnotation) | |
{ | |
return nil | |
} | |
var marker: RMMarker = RMMarker(mapboxMarkerImage: "bus", tintColor: UIColor.brownColor()) | |
marker.canShowCallout = true; | |
return marker | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it is not working.
should be
var annotation: RMAnnotation = RMAnnotation(mapView: mapView, coordinate: mapView.centerCoordinate, andTitle: "Bus Stop")
so layerForAnnotation delegate method will be successfully invoked and marker will be customized