Commit f70a0a84 by xuning

百度地图配置

parent 3bf1397e
......@@ -52,6 +52,7 @@
79DC8B902B8DABF900DBD8EA /* XVNewOrderAlter.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DC8B8F2B8DABF800DBD8EA /* XVNewOrderAlter.m */; };
79DC8B962B8DB05900DBD8EA /* XVGetOrderAlterButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DC8B952B8DB05900DBD8EA /* XVGetOrderAlterButtonView.m */; };
79DC8B992B8DB07A00DBD8EA /* XVGetOrderAlterSliderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DC8B982B8DB07A00DBD8EA /* XVGetOrderAlterSliderView.m */; };
79DC8B9D2B90813F00DBD8EA /* AppDelegate+ThirdParty.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DC8B9C2B90813E00DBD8EA /* AppDelegate+ThirdParty.m */; };
FA5E55D5A48FDC04BA4CCD08 /* Pods_fastservice.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08D109EE60B32403F3655A70 /* Pods_fastservice.framework */; };
/* End PBXBuildFile section */
......@@ -149,6 +150,8 @@
79DC8B952B8DB05900DBD8EA /* XVGetOrderAlterButtonView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVGetOrderAlterButtonView.m; sourceTree = "<group>"; };
79DC8B972B8DB07A00DBD8EA /* XVGetOrderAlterSliderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVGetOrderAlterSliderView.h; sourceTree = "<group>"; };
79DC8B982B8DB07A00DBD8EA /* XVGetOrderAlterSliderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVGetOrderAlterSliderView.m; sourceTree = "<group>"; };
79DC8B9B2B90813E00DBD8EA /* AppDelegate+ThirdParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+ThirdParty.h"; sourceTree = "<group>"; };
79DC8B9C2B90813E00DBD8EA /* AppDelegate+ThirdParty.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+ThirdParty.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -314,6 +317,8 @@
children = (
799DF0C42B6BD8AF00680907 /* AppDelegate.h */,
799DF0C52B6BD8AF00680907 /* AppDelegate.m */,
79DC8B9B2B90813E00DBD8EA /* AppDelegate+ThirdParty.h */,
79DC8B9C2B90813E00DBD8EA /* AppDelegate+ThirdParty.m */,
799DF0D02B6BD8B100680907 /* Assets.xcassets */,
799DF0D22B6BD8B100680907 /* LaunchScreen.storyboard */,
799DF0D52B6BD8B100680907 /* Info.plist */,
......@@ -592,6 +597,7 @@
79DC8B962B8DB05900DBD8EA /* XVGetOrderAlterButtonView.m in Sources */,
79DC8B872B8CD5F000DBD8EA /* XVOrderSettingView.m in Sources */,
7981EAB72B6E669000F357E7 /* UIScrollView+XVAdd.m in Sources */,
79DC8B9D2B90813F00DBD8EA /* AppDelegate+ThirdParty.m in Sources */,
7981EACF2B6F63CF00F357E7 /* XVMainJobViewController.m in Sources */,
799DF1042B6D220300680907 /* XVBaseViewController.m in Sources */,
79DC8B8A2B8D818000DBD8EA /* XVVerticalButton.m in Sources */,
......
//
// AppDelegate+ThirdParty.h
// fastservice
//
// Created by xuning on 2/29/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import "AppDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@interface AppDelegate (ThirdParty)
-(void)thirdPartyConfig:(UIApplication *)application WithOption:(NSDictionary *)launchOptions;
@end
NS_ASSUME_NONNULL_END
//
// AppDelegate+ThirdParty.m
// fastservice
//
// Created by xuning on 2/29/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import "AppDelegate+ThirdParty.h"
#import <IQKeyboardManager/IQKeyboardManager.h>
@interface AppDelegate(ThirdParty)<BMKGeneralDelegate,BMKLocationAuthDelegate>
@end
@implementation AppDelegate (ThirdParty)
-(void)thirdPartyConfig:(UIApplication *)application WithOption:(NSDictionary *)launchOptions {
[self setupIQKeyboard];
[self setupMapConfig];
}
- (void)setupIQKeyboard {
// 禁用IQKeyboardManager的自动工具条
[IQKeyboardManager sharedManager].enableAutoToolbar = NO;
//键盘和上面的占位提示框之间又一点间距,会很难看
[[IQKeyboardManager sharedManager]setKeyboardDistanceFromTextField:0];
[IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
}
- (void)setupMapConfig {
// 地图
_mapManager = [[BMKMapManager alloc]init];
BOOL ret = [_mapManager start:BAIDU_APPKEY generalDelegate:self];
if(!ret){
Log(@"哎呦,百度地图没有注册成功哦~");
}
// 定位
[[BMKLocationAuth sharedInstance] checkPermisionWithKey:BAIDU_APPKEY authDelegate:self];
// 导航
[BNaviService_Instance initNaviService:nil success:^{
[BNaviService_Instance authorizeNaviAppKey:BAIDU_APPKEY
completion:^(BOOL suc) {
Log(@"authorizeNaviAppKey ret = %d",suc);
}];
} fail:^{
Log(@"哎呦,百度地图导航没有注册成功哦~");
}];
}
- (void)onGetNetworkState:(int)iError{
if (0 == iError) {
Log(@"联网成功");
}else{
Log(@"onGetNetworkState %d",iError);
}
}
- (void)onGetPermissionState:(int)iError{
if (0 == iError) {
Log(@"授权成功");
}else {
Log(@"onGetPermissionState %d",iError);
}
}
@end
......@@ -7,7 +7,10 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>{
BMKMapManager *_mapManager;
}
@property (strong, nonatomic) UIWindow *window;
@end
......@@ -7,11 +7,11 @@
#import "AppDelegate.h"
#import <AvoidCrash.h>
#import <IQKeyboardManager/IQKeyboardManager.h>
#import "XVLoginViewController.h"
#import "XVNaviViewController.h"
#import "XVMainJobViewController.h"
#import "XVNewOrderAlter.h"
#import "AppDelegate+ThirdParty.h"
@interface AppDelegate ()
......@@ -36,29 +36,20 @@
XVNaviViewController *navi = [[XVNaviViewController alloc]initWithRootViewController:vc];
self.window.rootViewController = navi;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[self setupIQKeyboard];
[self thirdPartyConfig:application WithOption:launchOptions];
[XVNewOrderAlter show];
return YES;
}
- (void)setupIQKeyboard {
// 禁用IQKeyboardManager的自动工具条
[IQKeyboardManager sharedManager].enableAutoToolbar = NO;
//键盘和上面的占位提示框之间又一点间距,会很难看
[[IQKeyboardManager sharedManager]setKeyboardDistanceFromTextField:0];
[IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
}
@end
......@@ -9,5 +9,17 @@
</dict>
<key>UIFileSharingEnabled</key>
<true/>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>我们需要通过您的地理位置信息获取您附近的商家信息,以便获取更多订单</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>我们需要通过您的地理位置信息获取您附近的商家信息,以便获取更多订单</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>我们需要通过您的地理位置信息获取您附近的商家信息,以便获取更多订单</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>location</string>
<string>remote-notification</string>
</array>
</dict>
</plist>
......@@ -11,7 +11,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface XVNewOrderAlter : UIView
+ (void)show;
@end
NS_ASSUME_NONNULL_END
......@@ -8,14 +8,83 @@
#import "XVNewOrderAlter.h"
@interface XVNewOrderAlter()<BMKMapViewDelegate>
@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, strong) BMKMapView *mapView;
@end
@implementation XVNewOrderAlter
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
+ (void)show {
XVNewOrderAlter *view = [[XVNewOrderAlter alloc]init];
// 计算alter的高度
UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-16, SCREEN_HEIGHT)];
bgView.backgroundColor = [UIColor whiteColor];
[bgView addSubview:view];
[view mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(bgView);
}];
[bgView layoutIfNeeded];
bgView.height = view.height;
[LEEAlert alert].config
.LeeCustomView(bgView)
.LeeMaxWidth(SCREEN_WIDTH-16)
.LeeMaxHeight(SCREEN_HEIGHT)
.LeeHeaderInsets(UIEdgeInsetsMake(0, 0, 0, 0))
.LeeItemInsets(UIEdgeInsetsMake(0, 0, 0, 0))
.LeeClickBackgroundClose(NO)
.LeeCornerRadius(20.f)
.LeeShow();
}
- (void)dealloc {
Log(@"XVNewOrderAlter dealloc");
if (_mapView) {
_mapView.delegate = nil;
_mapView = nil;
}
}
*/
- (instancetype)initWithFrame:(CGRect)frame {
if(self = [super initWithFrame:frame]) {
[self setupUI];
}
return self;
}
- (void)setupUI {
self.backgroundColor = [UIColor redColor];
[self addSubview:self.mapView];
self.mapView.zoomLevel = 17;
[self addSubview:self.bottomView];
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self);
make.top.mas_equalTo(self.mapView.mas_bottom);
make.height.mas_equalTo(318);
}];
kViewBorderRadius(self.bottomView, 20, 0, [UIColor whiteColor]);
}
- (UIView *)bottomView {
if(_bottomView == nil) {
_bottomView = [[UIView alloc]init];
_bottomView.backgroundColor = [UIColor whiteColor];
}
return _bottomView;
}
- (BMKMapView *)mapView {
if(_mapView == nil) {
_mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth-16, 166)];
_mapView.delegate = self;
}
return _mapView;
}
@end
......@@ -22,11 +22,23 @@
#import "UINavigation+SXFixSpace.h"
#import "UIBarButtonItem+SXCreate.h"
#import<BaiduMapAPI_Base/BMKBaseComponent.h>
#import<BMKLocationKit/BMKLocationComponent.h>
#import<BaiduMapAPI_Map/BMKMapComponent.h>
#import<BaiduMapAPI_Search/BMKSearchComponent.h>
#import<BaiduMapAPI_Utils/BMKUtilsComponent.h>
#import <BaiduMapAPI_WalkNavi/BMKWalkNaviComponent.h>
#import <BaiduNaviKit-All/BNaviService.h>
#import<BaiduMapAPI_Map/BMKMapView.h>
#import "UIScrollView+XVAdd.h"
#import "UIView+XVAdd.h"
#import "NSString+XVAdd.h"
#endif
// 百度地图
#define BAIDU_APPKEY @"9fzRTgXAOSma0WLs5ko09vSuw4I6L7Oz"
#ifdef DEBUG
#define Log(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment