Skip to content

Instantly share code, notes, and snippets.

@davidm49090
Created January 27, 2015 23:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidm49090/bcb26d1b92cdee14daea to your computer and use it in GitHub Desktop.
Save davidm49090/bcb26d1b92cdee14daea to your computer and use it in GitHub Desktop.
// 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
}
}
@olame
Copy link

olame commented Jun 4, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment