Commit 2a783d1f authored by 汪林玲's avatar 汪林玲

ioS端插件

parent 06e01ca9
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
PODS:
- Flutter (1.0.0)
- tencent_map (0.0.1):
- Flutter
DEPENDENCIES:
- Flutter (from `Flutter`)
- tencent_map (from `.symlinks/plugins/tencent_map/ios`)
EXTERNAL SOURCES:
Flutter:
:path: Flutter
tencent_map:
:path: ".symlinks/plugins/tencent_map/ios"
SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
tencent_map: ac1cae67aa28e3b2bff2572e5ef5a282b74c1923
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.10.1
......@@ -3,13 +3,14 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 51;
objects = {
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
78275B473F0DB44771EF508E /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 208C91198F3A94B3BA6655C7 /* Pods_Runner.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
......@@ -31,10 +32,13 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
208C91198F3A94B3BA6655C7 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
29269BE0E0C5584634C58CB8 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
84F0457EAF1DFFFC6E68EC1E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -42,6 +46,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C2246583BB760C4F3410B31F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -49,12 +54,23 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78275B473F0DB44771EF508E /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
814A7BE9990A6490C69A9CD4 /* Pods */ = {
isa = PBXGroup;
children = (
84F0457EAF1DFFFC6E68EC1E /* Pods-Runner.debug.xcconfig */,
C2246583BB760C4F3410B31F /* Pods-Runner.release.xcconfig */,
29269BE0E0C5584634C58CB8 /* Pods-Runner.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
......@@ -72,6 +88,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
814A7BE9990A6490C69A9CD4 /* Pods */,
E21F0D0539E73642649D437C /* Frameworks */,
);
sourceTree = "<group>";
};
......@@ -98,6 +116,14 @@
path = Runner;
sourceTree = "<group>";
};
E21F0D0539E73642649D437C /* Frameworks */ = {
isa = PBXGroup;
children = (
208C91198F3A94B3BA6655C7 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -105,12 +131,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
2442092490241D4EC02D9D71 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
63EA2BEB66A5EF1C1DB4B92E /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
......@@ -169,6 +197,28 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
2442092490241D4EC02D9D71 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
......@@ -183,6 +233,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
63EA2BEB66A5EF1C1DB4B92E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
......@@ -294,7 +361,10 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
......@@ -407,7 +477,8 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
......@@ -420,13 +491,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 4R6KK56452;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
......@@ -453,7 +528,10 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
......
......@@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
......@@ -41,5 +41,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>需要定位</string>
</dict>
</plist>
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:tencent_map/tencent_map.dart';
void main() {
......@@ -31,7 +28,7 @@ class _MyAppState extends State<MyApp> {
body: Center(
child: GestureDetector(
onTap: () async {
Location location = await TencentMap.getLocation();
Location location = await TencentMap.getLocation(apiKey:'FJ5BZ-HJIW4-BORUH-XQNXR-PYSFE-CDBWB');
print("${location.name}-${location.address}-${location.city}-${location.cityCode}-${location.latitude}-${location.longitude}");
},
child: Text('Running on: $_platformVersion\n'),
......
import Flutter
import UIKit
public class SwiftTencentMapPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "tencent_map", binaryMessenger: registrar.messenger())
let instance = SwiftTencentMapPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
result("iOS " + UIDevice.current.systemVersion)
}
}
#import "TencentMapPlugin.h"
#if __has_include(<tencent_map/tencent_map-Swift.h>)
#import <tencent_map/tencent_map-Swift.h>
#else
// Support project import fallback if the generated compatibility header
// is not copied when this plugin is created as a library.
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
#import "tencent_map-Swift.h"
#endif
#import <TencentLBS/TencentLBS.h>
@interface TencentMapPlugin()<TencentLBSLocationManagerDelegate>
@property(nonatomic, retain) TencentLBSLocationManager *locationManager;
@end
@implementation TencentMapPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
[SwiftTencentMapPlugin registerWithRegistrar:registrar];
FlutterMethodChannel* channel = [FlutterMethodChannel methodChannelWithName:@"tencent_map" binaryMessenger:[registrar messenger]];
TencentMapPlugin* instance = [[TencentMapPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([@"getLocation" isEqualToString:call.method]) {
if(!self.locationManager){
self.locationManager = [[TencentLBSLocationManager alloc] init];
}
[self.locationManager setDelegate:self];
[self.locationManager setPausesLocationUpdatesAutomatically:NO];
[self.locationManager setRequestLevel:TencentLBSRequestLevelName];
NSString *apiKey = call.arguments[@"apiKey"];
[self.locationManager setApiKey:apiKey];
CLAuthorizationStatus authorizationStatus = [CLLocationManager authorizationStatus];
if (authorizationStatus == kCLAuthorizationStatusNotDetermined) {
[self.locationManager requestWhenInUseAuthorization];
return;
}
[self.locationManager requestLocationWithCompletionBlock:^(TencentLBSLocation *location, NSError *error) {
if(error){
result(@{@"code":@(-1),@"error":error});
}else{
CLLocation *clLocation = location.location;
CLLocationCoordinate2D coordinate=clLocation.coordinate;
NSDictionary *data = @{
@"name":location.name,
@"address":location.address,
@"city":location.city,
@"cityCode":location.code,
@"latitude":@(coordinate.latitude),
@"longitude":@(coordinate.longitude)
};
result(data);
}
}];
} else {
result(FlutterMethodNotImplemented);
}
}
@end
//
// TencentLBS.h
// TencentLBS
//
// Created by mirantslu on 16/4/19.
// Copyright © 2016年 Tencent. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for TencentLBS.
FOUNDATION_EXPORT double TencentLBSVersionNumber;
//! Project version string for TencentLBS.
FOUNDATION_EXPORT const unsigned char TencentLBSVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <TencentLBS/PublicHeader.h>
#import <TencentLBS/TencentLBSLocation.h>
#import <TencentLBS/TencentLBSLocationManager.h>
#import <TencentLBS/TencentLBSLocationUtils.h>
//
// TencentLBSLocation.h
// TencentLBS
//
// Created by mirantslu on 16/4/19.
// Copyright © 2016年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
NS_ASSUME_NONNULL_BEGIN
#define TENCENTLBS_DEBUG 0
@interface TencentLBSPoi : NSObject<NSSecureCoding, NSCopying>
@property (nonatomic, copy) NSString *uid; //!< 当前POI的uid
@property (nonatomic, copy) NSString *name; //!< 当前POI的名称
@property (nonatomic, copy) NSString *address; //!< 当前POI的地址
@property (nonatomic, copy) NSString *catalog; //!< 当前POI的类别
@property (nonatomic, assign) double longitude; //!< 当前POI的经度
@property (nonatomic, assign) double latitude; //!< 当前POI的纬度
@property (nonatomic, assign) double distance; //!< 当前POI与当前位置的距离
@end
@interface TencentLBSLocation : NSObject<NSSecureCoding, NSCopying>
/**
* 返回当前位置的CLLocation信息
*/
@property (nonatomic, strong) CLLocation *location;
/**
* 返回当前位置的行政区划, 0-表示中国大陆、港、澳, 1-表示其他
*/
@property (nonatomic, assign) NSInteger areaStat;
/**
* 返回室内定位楼宇Id
*/
@property (nonatomic, copy, nullable) NSString *buildingId;
/**
* 返回室内定位楼层
*/
@property (nonatomic, copy, nullable) NSString *buildingFloor;
/**
* 返回室内定位类型,0表示普通定位结果,1表示蓝牙室内定位结果
*/
@property (nonatomic, assign) NSInteger indoorLocationType;
/**
* 返回当前位置的名称,
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelName或TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *name;
/**
* 返回当前位置的地址
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelName或TencentLBSRequestLevelAdminName有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *address;
/**
* 返回当前位置的国家编码,目前暂不可用
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为0
*/
@property (nonatomic, assign) NSInteger nationCode;
/**
* 返回当前位置的城市编码
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *code;
/**
* 返回当前位置的国家
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *nation;
/**
* 返回当前位置的省份
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *province;
/**
* 返回当前位置的城市
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *city;
/**
* 返回当前位置的区县
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *district;
/**
* 返回当前位置的乡镇
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *town;
/**
* 返回当前位置的村
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *village;
/**
* 返回当前位置的街道
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *street;
/**
* 返回当前位置的街道编码
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelAdminName或TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, copy, nullable) NSString *street_no;
/**
* 返回当前位置周围的POI
* 仅当TencentLBSRequestLevel为TencentLBSRequestLevelPoi有返回值,否则为空
*/
@property (nonatomic, strong, nullable) NSArray<TencentLBSPoi*> *poiList;
/**
* 返回两个位置之间的横向距离
*/
- (double)distanceFromLocation:(const TencentLBSLocation *)location;
// 测试使用
#if TENCENTLBS_DEBUG
@property (nonatomic, copy, nullable) NSString *halleyTime;
#endif
@end
NS_ASSUME_NONNULL_END
//
// TencentLBSLocationManager.h
// TencentLBS
//
// Created by mirantslu on 16/4/19.
// Copyright © 2016年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import "TencentLBSLocation.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, TencentLBSRequestLevel) {
TencentLBSRequestLevelGeo = 0,
TencentLBSRequestLevelName = 1,
TencentLBSRequestLevelAdminName = 3,
TencentLBSRequestLevelPoi = 4,
};
typedef NS_ENUM(NSUInteger, TencentLBSLocationCoordinateType) {
TencentLBSLocationCoordinateTypeGCJ02 = 0, //!< 火星坐标,即国测局坐标
TencentLBSLocationCoordinateTypeWGS84 = 1, //!< 地球坐标,注:如果是海外,无论设置的是火星坐标还是地球坐标,返回的都是地球坐标
};
typedef NS_ENUM(NSUInteger, TencentLBSLocationError) {
TencentLBSLocationErrorUnknown = 0, //!< 错误码,表示目前位置未知,但是会一直尝试获取
TencentLBSLocationErrorDenied = 1, //!< 错误码,表示定位权限被禁止
TencentLBSLocationErrorNetwork = 2, //!< 错误码,表示网络错误
TencentLBSLocationErrorHeadingFailure = 3, //!< 错误码,表示朝向无法确认
TencentLBSLocationErrorOther = 4, //!< 错误码,表示未知错误
};
/**
* TencentLBSLocatingCompletionBlock 单次定位返回Block
*
* @param location 位置信息
* @param error 错误信息 参考 TencentLBSLocationError
*/
typedef void (^TencentLBSLocatingCompletionBlock)(TencentLBSLocation * _Nullable location, NSError * _Nullable error);
@protocol TencentLBSLocationManagerDelegate;
@interface TencentLBSLocationManager : NSObject
/**
* API Key, 在使用定位SDK服务之前需要先绑定key。
*/
@property (nonatomic, copy) NSString* apiKey;
/**
* 实现了 TencentLBSLocationManagerDelegate 协议的类指针。
*/
@property (nonatomic, weak) id<TencentLBSLocationManagerDelegate> delegate;
/**
* 设定定位的最小更新距离。默认为 kCLDistanceFilterNone。
*/
@property (nonatomic, assign) CLLocationDistance distanceFilter;
/**
* 设定定位精度。默认为 kCLLocationAccuracyBest 。
*/
@property (nonatomic, assign) CLLocationAccuracy desiredAccuracy;
/**
* 指定定位是否会被系统自动暂停。默认为 YES 。
*/
@property (nonatomic, assign) BOOL pausesLocationUpdatesAutomatically;
/**
* 是否允许后台定位。默认为 NO。
* iOS 9.0 以上用户需要设置该选项并且在info.list里面Background Modes 中的 Location updates 处于选中状态才可以使用后台定位权限。iOS 9.0之前可以直接申请总是使用的权限来获得后台定位。
*
* 设置为 YES 的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
*/
@property (nonatomic, assign) BOOL allowsBackgroundLocationUpdates;
/**
* 用户的活动类型
*
* 设置用户的活动类型。默认值为 CLActivityTypeOther
*/
@property (nonatomic, assign) CLActivityType activityType;
/**
* 设置当朝向改变时,每隔多少度调用一次
* 只有当设备方向的改变值超过该属性值时才激发delegate的方法。
*/
@property(nonatomic, assign) CLLocationDegrees headingFilter;
/**
* 设置设备当前的朝向
*/
@property(nonatomic, assign) CLDeviceOrientation headingOrientation;
/**
* 连续定位的逆地理信息请求的Level。默认为TencentLBSRequestLevelGeo
*/
@property (nonatomic, assign) TencentLBSRequestLevel requestLevel;
/**
* 返回的TencentLBSLocation的location字段的坐标类型。默认为TencentLBSLocationCoordinateTypeGCJ02。
*
* 在一次定位过程中,只允许设置一次,不允许重复设置
*/
@property (nonatomic, assign) TencentLBSLocationCoordinateType coordinateType;
/**
* 指定POI的更新间隔。 默认是10s
*/
@property(nonatomic, assign) NSInteger poiUpdateInterval;
#pragma mark -
- (void)requestWhenInUseAuthorization;
- (void)requestAlwaysAuthorization;
#pragma mark -
/**
* 单次定位
*
* 该方法为下面方法的一层封装。
* level默认是TencentLBSRequestLevelPoi
* timeout默认是10s
*/
- (BOOL)requestLocationWithCompletionBlock:(TencentLBSLocatingCompletionBlock)completionBlock;
/**
* 单次定位
*
* 注意:不能连续调用该接口,需在上一次返回之后才能再次发起调用。该接口兼容iOS 7.0及以上,因iOS 9.0系统提供单次定位能力,故在9.0以上会调用系统单次定位接口,9.0之前SDK完成封装。可以通过调用cancelRequestLocation来取消。
*
* @param level 可以根据此参数来对应的获取POI信息
* @param timeout 表示获取POI的超时时间。
* @param completionBlock 单次定位完成后的Block
*/
- (BOOL)requestLocationWithRequestLevel:(TencentLBSRequestLevel)level
locationTimeout:(NSTimeInterval)timeout
completionBlock:(TencentLBSLocatingCompletionBlock)completionBlock;
/**
* 取消单次定位
**/
- (void)cancelRequestLocation;
/**
* 开始连续定位
*/
- (void)startUpdatingLocation;
/**
* 停止连续定位
*/
- (void)stopUpdatingLocation;
/**
* 开启更新定位朝向
*/
- (void)startUpdatingHeading;
/**
* 结束更新定位朝向
*/
- (void)stopUpdatingHeading;
/**
* 停止展示定位朝向校准提示
*/
- (void)dismissHeadingCalibrationDisplay;
// 测试使用
#if TENCENTLBS_DEBUG
+ (void)upLoadData;
+ (NSData *)getLocationLog;
+ (void)newLocationLog;
#endif
@end
#pragma mark - TencentLBSLocationManagerDelegate
/**
* TencentLBSLocationManagerDelegate
* 定义了发生错误时的错误回调方法,连续定位的回调方法等。
*/
@protocol TencentLBSLocationManagerDelegate <NSObject>
@optional
/**
* 当定位发生错误时,会调用代理的此方法
*
* @param manager 定位 TencentLBSLocationManager 类
* @param error 返回的错误,参考 TencentLBSLocationError
*/
- (void)tencentLBSLocationManager:(TencentLBSLocationManager *)manager
didFailWithError:(NSError *)error;
/**
* 连续定位回调函数
*
* @param manager 定位 TencentLBSLocationManager 类
* @param location 定位结果
*/
- (void)tencentLBSLocationManager:(TencentLBSLocationManager *)manager
didUpdateLocation:(TencentLBSLocation *)location;
/**
* 定位权限状态改变时回调函数
*
* @param manager 定位 TencentLBSLocationManager 类
* @param status 定位权限状态
*/
- (void)tencentLBSLocationManager:(TencentLBSLocationManager *)manager
didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
/**
* 定位朝向改变时回调函数
*
* @param manager 定位 TencentLBSLocationManager 类
* @param newHeading 新的定位朝向
*/
- (void)tencentLBSLocationManager:(TencentLBSLocationManager *)manager
didUpdateHeading:(CLHeading *)newHeading;
/**
* 是否展示定位朝向校准提示的回调函数
*
* @param manager 定位 TencentLBSLocationManager 类
*/
- (BOOL)tencentLBSLocationManagerShouldDisplayHeadingCalibration:(TencentLBSLocationManager *)manager;
/**
* 只是内部调试使用,外部不应实现该接口
*/
- (void)tencentLBSLocationManager:(TencentLBSLocationManager *)manager didThrowLocation:(TencentLBSLocation *)location;
@end
NS_ASSUME_NONNULL_END
//
// TencentLBSLocationUtils.h
// TencentLBS
//
// Created by mirantslu on 16/8/11.
// Copyright © 2016年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@class TencentLBSLocation;
NS_ASSUME_NONNULL_BEGIN
@interface TencentLBSLocationUtils : NSObject
+ (double)distanceBetweenTwoCoordinate2D:(const CLLocationCoordinate2D *)coordinate coordinateTwo:(const CLLocationCoordinate2D *)coordinate2;
+ (double)distanceBetweenTwoCLLocations:(const CLLocation *)location locationTwo:(const CLLocation *)location2;
+ (double)distanceBetweenTwoTencentLBSLocations:(const TencentLBSLocation *)location locationTwo:(const TencentLBSLocation *)location2;
// 参数add表示是否要包括台湾,YES为包括, NO不包括
+ (BOOL) isInRegionWithLatitude:(double)latitude longitude:(double)longitude addTaiwan:(BOOL)add;
+ (CLLocationCoordinate2D)WGS84TOGCJ02:(CLLocationCoordinate2D)coordinate;
@end
@interface TencentLBSServiceManager : NSObject
/**
* 设置ID,如QQ号,微信号或是其他的登录账号,可用在发布前联调使用
*/
@property (atomic, copy) NSString *deviceID;
+ (instancetype)sharedInsance;
@end
NS_ASSUME_NONNULL_END
framework module TencentLBS {
umbrella header "TencentLBS.h"
export *
module * { export * }
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>Headers/TencentLBS.h</key>
<data>
hPC0/pGd4xrqNOXCT59Bc4EZx1o=
</data>
<key>Headers/TencentLBSLocation.h</key>
<data>
mB8TJCUqZuXtGDnENqpjCUZxXXY=
</data>
<key>Headers/TencentLBSLocationManager.h</key>
<data>
aYcvTq3T8uTCcURhHPxYuGxnlUY=
</data>
<key>Headers/TencentLBSLocationUtils.h</key>
<data>
7uMtNHoGSh/hHEdBq+CBUrK/ycA=
</data>
<key>Info.plist</key>
<data>
Ttlw1HDDeCgRqCR71JOv4XjfK4s=
</data>
<key>Modules/module.modulemap</key>
<data>
jS4bVEIZ8y6+mkDDypFhD0RkQVg=
</data>
</dict>
<key>files2</key>
<dict>
<key>Headers/TencentLBS.h</key>
<dict>
<key>hash</key>
<data>
hPC0/pGd4xrqNOXCT59Bc4EZx1o=
</data>
<key>hash2</key>
<data>
rXSLg9Gmqf/qi8hc0spd2V99ElDyGiIgDgvN30bahIQ=
</data>
</dict>
<key>Headers/TencentLBSLocation.h</key>
<dict>
<key>hash</key>
<data>
mB8TJCUqZuXtGDnENqpjCUZxXXY=
</data>
<key>hash2</key>
<data>
UtvJnD/4CBk/SN5aX25g0sCgen7djT1i08cKVZk3m04=
</data>
</dict>
<key>Headers/TencentLBSLocationManager.h</key>
<dict>
<key>hash</key>
<data>
aYcvTq3T8uTCcURhHPxYuGxnlUY=
</data>
<key>hash2</key>
<data>
z/k/uHBZqekDO/lZJkKhpGVonoRUeEkFjAdCCzxPdvo=
</data>
</dict>
<key>Headers/TencentLBSLocationUtils.h</key>
<dict>
<key>hash</key>
<data>
7uMtNHoGSh/hHEdBq+CBUrK/ycA=
</data>
<key>hash2</key>
<data>
rOb2VMDbxRXXWnD7IN9Yip2mAlPbbUb5GhB5K0p2ooE=
</data>
</dict>
<key>Modules/module.modulemap</key>
<dict>
<key>hash</key>
<data>
jS4bVEIZ8y6+mkDDypFhD0RkQVg=
</data>
<key>hash2</key>
<data>
j/3Yn2sASML4eiVUc877N1Qdw84cRUiapBx3Gc88OUI=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>
......@@ -5,19 +5,21 @@
Pod::Spec.new do |s|
s.name = 'tencent_map'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin.'
s.summary = 'A new flutter plugin project.'
s.description = <<-DESC
A new Flutter plugin.
A new flutter plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.platform = :ios, '8.0'
s.libraries = 'stdc++', 'z'
s.vendored_frameworks = 'Frameworks/TencentLBS.framework'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
end
......@@ -5,8 +5,8 @@ import 'package:flutter/services.dart';
class TencentMap {
static const MethodChannel _channel = const MethodChannel('tencent_map');
static Future<Location> getLocation() async {
Map map = await _channel.invokeMethod('getLocation');
static Future<Location> getLocation({String apiKey}) async {
Map map = await _channel.invokeMethod('getLocation',{'apiKey':apiKey});
return Location.form(map);
}
}
......
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