Sagit.Framework For IOS development framework introduction tutorial 14: stlocation obtaining map, GPS City, address, longitude, latitude, coordinate distance judgment, jump setting and third party map

Time:2020-10-18

preface:

This paper introduces the related functions of stlocation to obtain GPS coordinate information and jump to the third party map.

1. Basic definition of stlocation:

@interface STLocation : NSObject
typedef void (^OnLocationEnd)(STLocationModel *model);
@property (nonatomic,retain) STLocationModel *cityModel;
+ (instancetype)share;
-(void)runOnce;
-(void)start:(OnLocationEnd)locationEnd;
//! is GPS available
-(BOOL)isEnabled;

//! get the distance between coordinates (in meters)
-(double)distince:(double) lat1 lng1:(double) lng1 lat2:(double) lat2 lng2:(double) lng2;
#Jump to pragma mark
//! jump to system settings
-(void)redirectToSetting;
//! jump to third party map
-(void)redirectToMap;
-(void)redirectToMap:(STLocationModel*)mode;
@end

2. Examples of basic usage:

A. Get current coordinates, city, address:

    [Sagit.Location start:^(STLocationModel *model) {
        //model
    }];

B. Jump to third party map: use current coordinates, or specified coordinates.

Jump map:

[Sagit.Location redirectToMap];

C. Prompt the user to turn on GPS:

/Check if GPS is on
    if(!Sagit.Location.isEnabled)
    {
        [ self.msgBox  confirm:STString (@ "% @ function needs to turn on the position positioning function, which is used to get people nearby. Do you want to set it now?", menu_ Love) Title: @ "message prompt" click: ^ void (nsinteger, btnindex, UIAlertView * view){
            if(btnIndex==1)
            {
                [Sagit.Location redirectToSetting];
            }
        }Oktext: @ "Settings"];
    }

Conclusion:

The basic functions of GPS are introduced here.