IOS Baidu maps + Hawkeye SDK integrated memoir

IOS Baidu maps + Hawkeye SDK integrated memoir
Baidu Hawkeye

Eagle eye + map Baidu official integration instructions, in fact, has been very detailed, however, there are several pits or do not step on, do not know the series. I’m using the eagle eye V3.0.3 version here, listing some of the pits I stepped on during my integration process.

Hawkeye track itself only responsible for collecting and display trajectory point of the user information at the same time, SDK can complete sparse denoising, tied to the road function, but the processed information is still one of the scattered information, you need to combine Baidu maps SDK to be rendered as intuitively understood form of comparison good use is directly on the map draw line graph.

So you have to integrate Baidu maps, base, map, and location three sub components for the full use of all functions. The integration process follows Baidu’s official guidance. Here we do not mention the use of cocoapod import method, that will not be a problem, but will import a lot of unnecessary parts, manual integration, you can only use three sub packs, compression APP size.

The subcontract used by IOS Baidu maps + Hawkeye SDK integrated memoir

When you need to be integrated, BaiduMapAPI_Base.framework, BaiduMapAPI_Location.framework, BaiduMapAPI_Map.framework three package into the project, base package is all dependent on the base of the features of the package must be introduced.

Pit A: in the official integrated description, if you are a.M file to.Mm file, rather than choose “or the specified compile mode in engineering properties, namely the Xcode Project -&gt Edit Active Target; -> Compile Sources As Build to find Setting, and set it to” Objective-C++ “then, along the way to do so would report this error:

IOS Baidu maps + Hawkeye SDK integrated memoir
image.png

Just half a day later you might like me to try to compile Objective-C++, look no red compilation errors, but once tried to run and will find:

IOS Baidu maps + Hawkeye SDK integrated memoir
image.png

I guess your heart should break down. Then access to a lot of places, finally saw some slightly reliable explanation here, a brief summary is: automatic compilation mode (compile Source As is set to Automatic) according to the automatic selection of compiler language resource files, if designated by the compiler for C++, is part of the third party file cannot be successfully compiled by.

Then, in desperation, step by step, Linker command, failed, with, exit, and code errors were found at the addition of the.A static library, and at this point the compile mode was Automatic.

The practical solution here is..:

Copy the.A file to the project folder before adding it!

Copy the.A file to the project folder before adding it!

Copy the.A file to the project folder before adding it!

If only in accordance with the operation method of the official guide to the literature,.A static library has not been copied into the project, there is only one point to the logical address, and works in the compilation process is unable to project outside the package file execution and compilation of language identification!

IOS Baidu maps + Hawkeye SDK integrated memoir
compiles successfully

Copy the.A static library into the project folder and add it to the Link Binary With Libraries, and finally successfully completed the introduction of the Baidu map.

Contrary to the complexity of Baidu maps, the introduction of Hawkeye SDK is very simple and friendly. You just need to turn off the bitcode and drag framework into the project. One problem I have, however, is that the official Hawkeye demo can run on the simulator, while the official SDK does not run in the simulator. Compared with the SDK package found on both sides of the size is not the same, then use the lipo -info./BaiduTraceSDK.framework/BaiduTraceSDK command to check SDK support architecture, remembered I downloaded SDK has been synthesized according to the CPU architecture steps out of the official support part of the simulator, so SDK cannot run on the simulator. The reasons are as follows:

References: questions about iOS development of CPU architectures

The Xcode simulator is actually on the computer, so the iOS emulator does not use the arm instruction set. It compiles and runs using the x86 instruction set (or i386). While using in the real machine is the type of arm instruction set.

IOS Baidu maps + Hawkeye SDK integrated memoir
image.png
IOS Baidu maps + Hawkeye SDK integrated memoir
SDK contrast

The integration work has come to an end, and now coding.

First, set the didFinishLaunchingWithOptions method in Appdelegate.m:

#import "AppDelegate.h" #import < BaiduMapAPI_Base/BMKBaseComponent.h> #import; < BaiduTraceSDK/BaiduTraceSDK.h> @interface (< BMKGeneralDelegate> AppDelegate) - (BOOL) application: (UIApplication * application) didFinishLaunchingWithOptions: (NSDictionary *) launchOptions Override point for customization after {/ / application / / launch. set based BTKServiceOption information *basicInfoOption Hawkeye SDK = [[BTKServiceOption alloc]initWithAK:@ "Hawkeye AK you" mcode:@ "your keepAlive:YES] [[BTKAction Hawkeye mcode" serviceID:100000; sharedInstance] initInfo:basicInfoOption]; SDK BMKMapManager *mapManager / / initialize the map = [[BMKMapManager alloc]init]; if [mapManager start:@ ("Baidu map key" you generalD Elegate:self] NSLog (@ manager) {}; start ") return YES;} - (void) onGetNetworkState: (int iError) {if (0 = = iError) {NSLog (@" networking success ");} else{(NSLog @ onGetNetworkState%d", iError);}} - (void) onGetPermissionState: (int iError) {if (0 = = iError) {NSLog (@ "authorized");} else {NSLog (@ onGetPermissionState%d ", iError);}}

Next, turn on the background and open the permissions. You have to open it, otherwise the eagle eye will crash:

IOS Baidu maps + Hawkeye SDK integrated memoir
opens the background positioning authority

Then call the relevant functions in ViewController:

- (void) viewDidLoad viewDidLoad] if ({[super; self.mapview = = Nil) {self.mapview [[BMKMapView = alloc]initWithFrame:CGRectMake (0, 0, 414, 414)]}; [self.view addSubview:self.mapview]; _mapview.showsUserLocation = YES; _mapview.userTrackingMode = BMKUserTrackingModeFollow; if (self.locationService = = Nil) {self.locationService [[BMKLocationService = alloc]init]; self.locationService.delegate = self;} [_locationService startUserLocationService]; BTKStartServiceOption *option [[BTKStartServiceOption alloc]initWithEntityName:@ = "YYDemo"]; [[BTKAction sharedInstance] startService:option delegate:self]; [[BTKAction sharedInstance] startGather:self];} - (void) viewWi LlAppear: (BOOL) animated{[super viewWillAppear:animated]; self.mapview.delegate = self; self.mapview.zoomLevel = 18.5;} - (void) viewWillDisappear: (BOOL) animated{[super viewWillDisappear:animated]; _mapview.delegate = nil; "BTKAction sharedInstance] stopGather:self] [[BTKAction; sharedInstance] stopService:self];}

Finally, don’t forget to add two entries in the Info.plist that allow you to locate the permissions and bundle display name, so that the underlying integration should be completed successfully.

Hawkeye track default mode is collected once every five seconds, every thirty seconds once uploaded, you can according to your need to customize these parameters, and improve the precision of positioning note frequency will greatly enhance the power consumption.

Say how to query the history path:

- (void) touchesBegan: (NSSet< UITouch *> touches withEvent: (* *) UIEvent event{) BTKQueryTrackProcessOption *options / / structure request object = [[BTKQueryTrackProcessOption alloc]init]; options.denoise = true; / / true / / options.vacuate = whether noise reduction; whether sparsing options.mapMatch = true; options.transportMode = BTK_TRACK_PROCESS_OPTION_TRANSPORT_MODE_WALKING / be tied; / / set endTime = NSUInteger motion mode [[NSDate date] timeIntervalSince1970]; / / query over the past 24 hours BTKQueryHistoryTrackRequest *request = [[BTKQueryHistoryTrackRequest alloc] initWithEntityName:@ track "YYDemo startTime:endTime" - 86400 endTime:endTime isProcessed:TRUE processOption:options supplementMode:BTK_TRACK_PRO CESS_OPTION_SUPPLEMENT_MODE_RIDING outputCoordType:BTK_COORDTYPE_BD09LL sortType:BTK_TRACK_SORT_TYPE_DESC pageIndex:1 pageSize:50 serviceID:147404 tag:0]; / / [[BTKTrackAction sharedInstance] queryHistoryTrackWith:request delegate:self] launched a search request;}

Then, here is the callback method for query results. I use the historical track point information I’ve searched to combine the lines on the Baidu map to map the historical trajectories on the map view.

- (void) onQueryHistoryTrack: (NSData *) response{NSDictionary *dict [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments = error:nil]; NSLog (@ "track history, Dict response:% @"); NSArray *arr dict[@ = "points"]; CLLocationCoordinate2D paths[arr.count]; NSMutableArray *colors = [[NSMutableArray alloc]init]; for (NSInteger I = 0; I < arr.count; i++) {NSDictionary *point = arr[i]; paths[i] = CLLocationCoordinate2DMake ([point[@ "latitude" doubleValue], [point[@ "longitude" doubleValue] "); UIColor *color = [UIColor redColor]; [colors addObject:color]; BMKPolyline *colorfulPloyLine = [BMKPolyline polylineWithCoordinates:paths count:arr.count]}; [_mapview addOverlay:colorfulPloyLine];} / / overlay to generate the corresponding View (BMKOverlayView *) mapView: (* BMKMapView) mapView viewForOverlay: (ID < BMKOverlay> overlay) {if ([overlay isKindOfClass:[BMKPolyline class]]) {BMKPolylineView* polylineView = [[BMKPolylineView alloc] initWithOverlay:overlay]; polylineView.lineWidth = 3; / / / use the segmentation of color rendering, must be set (the content must be UIColor polylineView.strokeColor) = [UIColor redColor]; return polylineView;} return nil;}

The effect is this:

IOS Baidu maps + Hawkeye SDK integrated memoir
noise tied road before
IOS Baidu maps + Hawkeye SDK integrated memoir
noise tied Road

This is the end of the eagle eye SDK integration. Thank you for reading.