Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tencent_map
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
tencent_map
Commits
0df5a9a7
Commit
0df5a9a7
authored
Jul 20, 2021
by
汪林玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加gps和打开gps判断
parent
2a783d1f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
78 additions
and
8 deletions
+78
-8
android/src/main/java/com/lzq/tencent_map/TencentMapPlugin.java
...d/src/main/java/com/lzq/tencent_map/TencentMapPlugin.java
+29
-2
example/ios/Podfile.lock
example/ios/Podfile.lock
+2
-2
example/lib/main.dart
example/lib/main.dart
+13
-1
example/pubspec.lock
example/pubspec.lock
+1
-1
ios/Classes/TencentMapPlugin.m
ios/Classes/TencentMapPlugin.m
+12
-0
ios/tencent_map.podspec
ios/tencent_map.podspec
+1
-1
lib/tencent_map.dart
lib/tencent_map.dart
+19
-0
pubspec.yaml
pubspec.yaml
+1
-1
No files found.
android/src/main/java/com/lzq/tencent_map/TencentMapPlugin.java
View file @
0df5a9a7
package
com.lzq.tencent_map
;
package
com.lzq.tencent_map
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.location.LocationManager
;
import
android.provider.Settings
;
import
android.util.Log
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
import
io.flutter.embedding.engine.plugins.FlutterPlugin
;
import
io.flutter.embedding.engine.plugins.FlutterPlugin
;
...
@@ -7,12 +13,14 @@ import io.flutter.plugin.common.MethodCall;
...
@@ -7,12 +13,14 @@ import io.flutter.plugin.common.MethodCall;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
;
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
;
import
io.flutter.plugin.common.MethodChannel.Result
;
import
io.flutter.plugin.common.MethodChannel.Result
;
import
io.flutter.plugin.common.PluginRegistry.Registrar
;
/**
/**
* TencentMapPlugin
* TencentMapPlugin
*/
*/
public
class
TencentMapPlugin
implements
FlutterPlugin
,
MethodCallHandler
{
public
class
TencentMapPlugin
implements
FlutterPlugin
,
MethodCallHandler
{
public
final
static
String
TAG
=
"TencentMapPlugin"
;
/// The MethodChannel that will the communication between Flutter and native Android
/// The MethodChannel that will the communication between Flutter and native Android
///
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
...
@@ -20,17 +28,36 @@ public class TencentMapPlugin implements FlutterPlugin, MethodCallHandler {
...
@@ -20,17 +28,36 @@ public class TencentMapPlugin implements FlutterPlugin, MethodCallHandler {
private
MethodChannel
channel
;
private
MethodChannel
channel
;
private
Handler
handler
;
private
Handler
handler
;
private
Context
context
;
@Override
@Override
public
void
onAttachedToEngine
(
@NonNull
FlutterPluginBinding
flutterPluginBinding
)
{
public
void
onAttachedToEngine
(
@NonNull
FlutterPluginBinding
flutterPluginBinding
)
{
context
=
flutterPluginBinding
.
getApplicationContext
();
channel
=
new
MethodChannel
(
flutterPluginBinding
.
getBinaryMessenger
(),
"tencent_map"
);
channel
=
new
MethodChannel
(
flutterPluginBinding
.
getBinaryMessenger
(),
"tencent_map"
);
channel
.
setMethodCallHandler
(
this
);
channel
.
setMethodCallHandler
(
this
);
handler
=
new
Handler
(
flutterPluginBinding
.
getApplicationContext
()
);
handler
=
new
Handler
(
context
);
}
}
@Override
@Override
public
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
Result
result
)
{
public
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
Result
result
)
{
if
(
call
.
method
.
equals
(
"getLocation"
))
{
if
(
call
.
method
.
equals
(
"getLocation"
))
{
handler
.
getLocation
(
result
);
handler
.
getLocation
(
result
);
}
else
if
(
"isOpenGPS"
.
equals
(
call
.
method
)){
LocationManager
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
boolean
gps
=
locationManager
.
isProviderEnabled
(
android
.
location
.
LocationManager
.
GPS_PROVIDER
);
boolean
network
=
locationManager
.
isProviderEnabled
(
LocationManager
.
NETWORK_PROVIDER
);
if
(
gps
||
network
)
{
result
.
success
(
true
);
}
else
{
result
.
success
(
false
);
}
}
else
if
(
"enableGPS"
.
equals
(
call
.
method
)){
Intent
intent
=
new
Intent
(
Settings
.
ACTION_LOCATION_SOURCE_SETTINGS
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
context
.
startActivity
(
intent
);
result
.
success
(
true
);
}
else
{
}
else
{
result
.
notImplemented
();
result
.
notImplemented
();
}
}
...
...
example/ios/Podfile.lock
View file @
0df5a9a7
PODS:
PODS:
- Flutter (1.0.0)
- Flutter (1.0.0)
- tencent_map (
0.0.1
):
- tencent_map (
1.0.0
):
- Flutter
- Flutter
DEPENDENCIES:
DEPENDENCIES:
...
@@ -15,7 +15,7 @@ EXTERNAL SOURCES:
...
@@ -15,7 +15,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
tencent_map:
ac1cae67aa28e3b2bff2572e5ef5a282b74c1923
tencent_map:
2258908e7e400e6061a3bd0a173e2f2f9fa80fbf
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
...
...
example/lib/main.dart
View file @
0df5a9a7
...
@@ -23,7 +23,19 @@ class _MyAppState extends State<MyApp> {
...
@@ -23,7 +23,19 @@ class _MyAppState extends State<MyApp> {
return
MaterialApp
(
return
MaterialApp
(
home:
Scaffold
(
home:
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
title:
const
Text
(
'Plugin'
),
actions:
[
IconButton
(
icon:
Text
(
'isGPS'
),
onPressed:
(){
TencentMap
.
isOpenGPS
().
then
((
value
){
print
(
"----------------------------------GPS是否开启:
$value
"
);
});
}),
IconButton
(
icon:
Text
(
'openGPS'
),
onPressed:
(){
TencentMap
.
enableGPS
().
then
((
value
){
print
(
"----------------------------------打开GPS:
$value
"
);
});
})
],
),
),
body:
Center
(
body:
Center
(
child:
GestureDetector
(
child:
GestureDetector
(
...
...
example/pubspec.lock
View file @
0df5a9a7
...
@@ -127,7 +127,7 @@ packages:
...
@@ -127,7 +127,7 @@ packages:
path: ".."
path: ".."
relative: true
relative: true
source: path
source: path
version: "
0.0.1
"
version: "
1.0.0
"
term_glyph:
term_glyph:
dependency: transitive
dependency: transitive
description:
description:
...
...
ios/Classes/TencentMapPlugin.m
View file @
0df5a9a7
#import "TencentMapPlugin.h"
#import "TencentMapPlugin.h"
#import <TencentLBS/TencentLBS.h>
#import <TencentLBS/TencentLBS.h>
#import <CoreLocation/CoreLocation.h>
@interface
TencentMapPlugin
()
<
TencentLBSLocationManagerDelegate
>
@interface
TencentMapPlugin
()
<
TencentLBSLocationManagerDelegate
>
...
@@ -48,6 +49,17 @@
...
@@ -48,6 +49,17 @@
result
(
data
);
result
(
data
);
}
}
}];
}];
}
else
if
([
@"isOpenGPS"
isEqualToString
:
call
.
method
])
{
if
([
CLLocationManager
locationServicesEnabled
]
==
YES
){
result
(
@YES
);
}
else
{
result
(
@NO
);
}
}
else
if
([
@"enableGPS"
isEqualToString
:
call
.
method
])
{
NSURL
*
url
=
[
NSURL
URLWithString
:
UIApplicationOpenSettingsURLString
];
if
([[
UIApplication
sharedApplication
]
canOpenURL
:
url
])
{
[[
UIApplication
sharedApplication
]
openURL
:
url
];
}
}
else
{
}
else
{
result
(
FlutterMethodNotImplemented
);
result
(
FlutterMethodNotImplemented
);
}
}
...
...
ios/tencent_map.podspec
View file @
0df5a9a7
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#
#
Pod
::
Spec
.
new
do
|
s
|
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
'tencent_map'
s
.
name
=
'tencent_map'
s
.
version
=
'
0.0.1
'
s
.
version
=
'
1.0.0
'
s
.
summary
=
'A new flutter plugin project.'
s
.
summary
=
'A new flutter plugin project.'
s
.
description
=
<<-
DESC
s
.
description
=
<<-
DESC
A new flutter plugin project.
A new flutter plugin project.
...
...
lib/tencent_map.dart
View file @
0df5a9a7
...
@@ -5,10 +5,29 @@ import 'package:flutter/services.dart';
...
@@ -5,10 +5,29 @@ import 'package:flutter/services.dart';
class
TencentMap
{
class
TencentMap
{
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'tencent_map'
);
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'tencent_map'
);
///
/// 获取GPS定位
/// [apiKey] 腾讯地图官方库
///
static
Future
<
Location
>
getLocation
({
String
apiKey
})
async
{
static
Future
<
Location
>
getLocation
({
String
apiKey
})
async
{
Map
map
=
await
_channel
.
invokeMethod
(
'getLocation'
,{
'apiKey'
:
apiKey
});
Map
map
=
await
_channel
.
invokeMethod
(
'getLocation'
,{
'apiKey'
:
apiKey
});
return
Location
.
form
(
map
);
return
Location
.
form
(
map
);
}
}
///
/// 是否打开GPS
///
static
Future
<
bool
>
isOpenGPS
()
async
{
return
await
_channel
.
invokeMethod
(
'isOpenGPS'
);
}
///
/// 启用GPS
///
static
Future
<
bool
>
enableGPS
()
async
{
return
await
_channel
.
invokeMethod
(
'enableGPS'
);
}
}
}
class
Location
{
class
Location
{
...
...
pubspec.yaml
View file @
0df5a9a7
name
:
tencent_map
name
:
tencent_map
description
:
A new Flutter plugin.
description
:
A new Flutter plugin.
version
:
0.0.1
version
:
1.0.0
author
:
author
:
homepage
:
homepage
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment