前言:
本篇介紹框架里關于STLocation 獲取GPS坐標資訊、跳轉第三方地圖的相關功能,
1、STLocation基本定義:
@interface STLocation : NSObject typedef void (^OnLocationEnd)(STLocationModel *model); @property (nonatomic,retain) STLocationModel *cityModel; + (instancetype)share; -(void)runOnce; -(void)start:(OnLocationEnd)locationEnd; //!是否可用GPS -(BOOL)isEnabled; //!獲取坐標間的距離(單位米) -(double)distince:(double) lat1 lng1:(double) lng1 lat2:(double) lat2 lng2:(double) lng2; #pragma mark 跳轉 //!跳轉到系統設定界面 -(void)redirectToSetting; //!跳轉到第3方地圖 -(void)redirectToMap; -(void)redirectToMap:(STLocationModel*)mode; @end
2、基本用法示例:
A、獲取當前坐標、城市、地址:
[Sagit.Location start:^(STLocationModel *model) { //model }];
B、跳轉第三方地圖:使用當前坐標、或指定的坐標,
可跳轉的地圖:

[Sagit.Location redirectToMap];
C、提示用戶開啟GPS:
/檢測設備是否開啟GPS if(!Sagit.Location.isEnabled) { [self.msgBox confirm:STString(@"%@功能需要開啟位置定位功能,用于獲取附近的人,是否現在設定?",Menu_Love) title:@"訊息提示" click:^void(NSInteger btnIndex, UIAlertView *view) { if(btnIndex==1) { [Sagit.Location redirectToSetting]; } } okText:@"設定"]; }
總結結束:
GPS的基本功能介紹到此為此,
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/106748.html
標籤:其他
上一篇:Flutter如何有效地退出程式
