Select to view content in your preferred language

how to use AGSGPS?

2591
18
07-30-2010 12:35 AM
JungMinKim
New Contributor
I get the current coordinate using CLLoationManager. But, I don't know exactly how to use AGSGPS.
Is there any sample for AGSGPS?
0 Kudos
18 Replies
NimeshJarecha
Esri Regular Contributor
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
0 Kudos
KOLDODUARTE
Emerging Contributor
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

That also already I have done it, but my custom PNG does not appear, the blue symbol default does not want to go away !
0 Kudos
KOLDODUARTE
Emerging Contributor
Dear Nimesh

Still not able to see my GPS icon. I attach you a screen capture of the form to add a file in the project.

Do you know the setting needed for this icon?

BR

Koldo
0 Kudos
NimeshJarecha
Esri Regular Contributor
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
0 Kudos
KOLDODUARTE
Emerging Contributor
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


Thanks Nimesh for your anwers. But still we are not able to use our own icon for GPS. We look into your project and we tried to rename your GpsDisplay.png to GpsDisplay_.png and "Clean all" and the project keeps putting your custom icon. Strange!

In the other side, our project is a Project Base type. We do not have a resource folder as yours.

Thanks again and hope you can help us with this matter

Koldo
0 Kudos
NimeshJarecha
Esri Regular Contributor
Instead of renaming, remove the image from project as well as from disk and then "Clean All".

Also, is it possible to attach your sample project so I can have a look at it. You can email me at njarecha@esri.com.

Regards,
Nimesh
0 Kudos
KOLDODUARTE
Emerging Contributor
Thanks Nimesh for your e-mail.

I will explain the solution:

In my project (Window-based application UNIVERSAL), I have not any "Resources" folder. And the solution is:
In your project, you must have 2 png with this names:

  • GpsDisplay.png

  • GpsDisplayHeading.png

Now, you can see your custom png file on your map!

Thanks again Nimesh !!

Best regards,
Koldo.
0 Kudos
PaulJereb
Emerging Contributor
Hello!

I tried to add the code suggested by Jeremy but mapViewDidLoad is never called.

#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");
  
 } 
 
} 


If I add the following code to viewDidLoad, it tells me that GPS is not enabled (in the simulator). When I run the official MapViewDemo it works though...

       [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");
  
 }


My MapServer uses EPSG:31259 as the spatial reference. Does the mapView take care of the transformation from WGS84?

Paul
0 Kudos
JeremyBixby
Regular Contributor
Paul,

That method is part of the AGSMapViewDelegate protocol, so you've got to implement that in a different class that uses that AGSMapViewDelegate.  You then need to give the delegate to the mapView, but be careful to assign it as the mapViewDelegate and not just the delegate.  I have pasted some code below:

the map delegate header:
#import <UIKit/UIKit.h>
#import "ArcGIS.h"

@interface iLenexaMapsDelegate : UIViewController
<AGSMapViewDelegate, UIScrollViewDelegate>
{}

@end


the map delegate implementation:
#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


How to create a mapViewDelegate and assign it to a mapView:

// 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
}
0 Kudos