how to use AGSGPS?

1371
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
JeremyBixby
New Contributor III
Think of AGSGPS as the mapView's window to CoreLocation.  To access the properties & methods of the AGSGPS object, you access the gps property on the mapView object.  To have the mapView start responding to CoreLocation services, call the [mapView.gps start] method.  The currentPoint property on AGSGPS will give you the iPhone's current location.  Here is a sample snippet from a mapDelegate:


- (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");
  
 } 
}
0 Kudos
JungMinKim
New Contributor
Thanks! I can display the current location.
0 Kudos
KOLDODUARTE
New Contributor
Thanks! I can display the current location.


Now, How you can go zoom until your current location?

Thanks!
0 Kudos
JeremyBixby
New Contributor III
This ought to happen for you automatically, if you've got the AGSGPS turned on.  If you are talking about something like a button to go back to your current point after you've been panning around the map, I would modify and use Divesh's code at the end of this thread:

http://forums.arcgis.com/threads/7150-How-to-map-zoom-in-level

Get the currentPoint object, and set the parameters on the AGSMutableEnvelope to something appropriate, according to your x and y from the currentPoint on the AGSGPS object.  Then call

[self.mapView zoomToEnvelope:newEnvelopeBasedOnCurrentLocation animated:YES];
0 Kudos
KOLDODUARTE
New Contributor
Thanks! I can display the current location.


I am not able to finally make the AGSGPS work.

Please could you provide me the sample of code that works for you?

Thanks in advance
0 Kudos
KOLDODUARTE
New Contributor
Thank  you all,

Definetly Ive been able to make it work. But I have a last question: is there a way to modify the symbology of the GPS point? (e.g. apply a custom png)

Thanks again!
0 Kudos
JeremyBixby
New Contributor III
From the class documentation:

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.
0 Kudos
KOLDODUARTE
New Contributor
From the class documentation:


I have a custom PNG with this name and this size, but now I don't know how to include this picture in the application bundle. Could you help me?

Thanks again !
0 Kudos
KOLDODUARTE
New Contributor
Well, I am in the Info.plist where my application bundle settings are, and I don´t know how to set the key for the GPS icon.

Thanks for all!
0 Kudos