Route-Me 앱에 다음 항목을 추가하려고했습니다.iOS Route-Me : 사용자 위치 마커 추가
- 는
- 가 새 위치
내가 MapBox의 IOS의 예에서 기본 예제를 사용하고 있습니다에 마커를 이동
이 내 헤더 파일입니다
#import <UIKit/UIKit.h>
#import "RMMapView.h"
#import "RMMarker.h"
#import "RMMapViewDelegate.h"
#import "RMMarkerManager.h"
#import "CoreLocation/CoreLocation.h"
@interface MBTiles_ExampleViewController : UIViewController
{
RMMapView *mapView;
}
@property (nonatomic, retain) IBOutlet RMMapView *mapView;
@property (nonatomic, retain) CLLocationManager *locationManager;
@property (nonatomic, retain) CLLocation *currentLocation;
@property (nonatomic, retain) RMMarkerManager *markerManager;
@property (nonatomic, retain) RMMarker *locationMarker;
@end
그리고 이것은 내 구현 파일입니다
#define kStartingLat 30.0f
#define kStartingLon -10.0f
#define kStartingZoom 1.5f
#import "MBTiles_ExampleViewController.h"
#import "RMMBTilesTileSource.h"
#import "RMMapContents.h"
#import "RMMarker.h"
#import "RMMarkerManager.h"
#import "CoreLocation/CoreLocation.h"
@implementation MBTiles_ExampleViewController
@synthesize mapView;
@synthesize currentLocation;
@synthesize locationManager;
@synthesize markerManager;
@synthesize locationMarker;
(void)viewDidLoad
{
CLLocationCoordinate2D startingPoint;
startingPoint.latitude = kStartingLat;
startingPoint.longitude = kStartingLon;
NSURL *tilesURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"control-room-0.2.0" ofType:@"mbtiles"]];
RMMBTilesTileSource *source = [[[RMMBTilesTileSource alloc] initWithTileSetURL:tilesURL] autorelease];
[[[RMMapContents alloc] initWithView:self.mapView
tilesource:source
centerLatLon:startingPoint
zoomLevel:kStartingZoom
maxZoomLevel:[source maxZoom]
minZoomLevel:[source minZoom]
backgroundImage:nil] autorelease];
mapView.enableRotate = NO;
mapView.deceleration = NO;
mapView.backgroundColor = [UIColor blackColor];
mapView.contents.zoom = kStartingZoom;
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
UIImage *iconImage = [UIImage imageNamed:@"marker.png"];
locationMarker = [[RMMarker alloc] initWithUIImage: iconImage];
[markerManager addMarker: locationMarker AtLatLong: startingPoint];
}
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
[mapView moveToLatLong:newLocation.coordinate];
RMLatLong newCoords = {newLocation.coordinate.latitude, newLocation.coordinate.longitude};
if (nil != markerManager)
[markerManager moveMarker:locationMarker AtLatLon: newCoords];
}
(void)dealloc
{
[mapView release];
[super dealloc];
}
@end
marker.png 내 자원 폴더에 추가되었습니다.
그래서 내 질문
는 는-
?
- SnowLeopard에서 xcode를 사용하고있어서 시뮬레이터가 실제로 내 위치를 찾을 수 있습니까? 지도가 움직이지 않기 때문에.
많은 코드 스 니펫 및 자습서를 시도했지만 아무도 작동하지 않아 도움이 될 수 있으면 도움이 될 것입니다. 사과 문서에서 두 번째 질문에 대해서는
NSLog (@ "Text goes here")를 추가하십시오. 코드를 통해 디버그 출력을 인쇄하는 행. 표시하려는 위치, 이미지가 nil인지, 이미지의 크기인지, 코드가 호출되는지 여부 등을 확인하고자 할 것입니다. –