- (void)mapViewDidLoad:(AGSMapView *) mapView{ [mapView.gps start]; if (!mapView.gps.enabled) { NSLog(@The GPS is not enabled); } else if (mapView.gps.enabled) { NSLog(@The GPS is enabled); } }
Thanks! I can display the current location.
By default, the map uses a round, blue symbol to display the current location. You can replace this symbol with an image icon of your choice. This image must be included in the application bundle, it must be named GpsDisplay.png and it must be 35x35 pixels in size.
From the class documentation:
In your XCode project, select "Resources" folder >> Right click and select "Add" >> Existing Files.. >> Browse to your custom GpsDisply.png file and add it.Hope this helps!Regards,Nimesh
Please find attached MapViewDemo sample where I've changed GPS display image. While adding image to the project, the checkbox, "Copy item..." selected in addition to the setting you have. Please make sure, if have that blue symbol image in your project then remove it and rebuild the project.Regards,Nimesh
#pragma mark AGSMapViewDelegate //called when the map view is loaded (after the view is loaded) - (void)mapViewDidLoad:(AGSMapView *)mapView { NSLog(@mapView is loaded); [mapView.gps start]; if (!mapView.gps.enabled) { NSLog(@The GPS is not enabled); } else if (mapView.gps.enabled) { NSLog(@The GPS is enabled); } }
[self.mapView.gps start]; if (!self.mapView.gps.enabled) { NSLog(@The GPS is not enabled); } else if (self.mapView.gps.enabled) { NSLog(@The GPS is enabled); }
#import <UIKit/UIKit.h> #import "ArcGIS.h" @interface iLenexaMapsDelegate : UIViewController <AGSMapViewDelegate, UIScrollViewDelegate> {} @end
#import "iLenexaMapsDelegate.h" #import "iLenexaModel.h" #import "iLenexaMapView.h" @implementation iLenexaMapsDelegate - (void)mapViewDidLoad:(AGSMapView *) mapView{ [mapView.gps start]; mapView.gps.autoPan = YES; if(!mapView.gps.enabled){ NSLog(@The GPS is NOT enabled!); } else if (mapView.gps.enabled){ NSLog(@The GPS IS IN FACT enabled...); } } -(void)mapViewDidEndPanning:(AGSMapView *) mapView{ NSLog(@The map view did end panning); iLenexaModel *myModel = [iLenexaModel sharedModel]; myModel.currLocation = mapView.gps.currentPoint; } -(void)mapViewDidEndZooming:(AGSMapView *) mapView{ NSLog(@The map view did end zooming); } -(void)mapView:(AGSMapView *) mapView didAddLayerView:(id) layerView{ //Need to set the default alpha parameters on each layer... } -(void)mapView:(AGSMapView *) mapView didChangeEnvelope:(AGSEnvelope *) envelope{} /* // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { // Custom initialization } return self; } */ /* // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { } */ /* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } */ // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations //return (interfaceOrientation == UIInterfaceOrientationPortrait); return YES; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; mapsDelegate = [[iLenexaMapsDelegate alloc] init]; mapView.mapViewDelegate = mapsDelegate; //...and so on }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.