tencent_map_flutter 0.1.0 copy "tencent_map_flutter: ^0.1.0" to clipboard
tencent_map_flutter: ^0.1.0 copied to clipboard

A Flutter plugin that integrated Tencent Map SDK, support Android and iOS.

Tencent Map for Flutter #

pub package

A Flutter plugin that provides a Tencent Map widget.

Android iOS
Support SDK 21+ iOS 12+

Usage #

To use this plugin, add tencent_map_flutter as a dependency in your pubspec.yaml file.

Getting Started #

Log in to the Tencent Map Services console to get an API key at https://lbs.qq.com/dev/console/application/mine;

  • Go to Tencent Map Service Console, expand the Application Management menu and select My Apps;
  • Click Create Application on the right, if you have already created an application, you can directly select Add Key;
  • Check the Map SDK feature in the panel, and optionally enter the authorization package name in the input box below (the key can only be used by the app corresponding to the package name);

Android #

  1. Set the minSdkVersion in example/android/app/build.gradle:
android {
    defaultConfig {
        minSdkVersion 21
    }
}

This means that app will only be available for users that run Android SDK 21 or higher.

  1. Specify your API key in the application manifest example/android/app/src/main/AndroidManifest.xml:
<manifest ...>
  <application ...>
    <meta-data
      android:name="TencentMapSDK"
      android:value="YOUR KEY HERE"/>

iOS #

To set up, specify your API key in the application delegate ios/Runner/AppDelegate.m:

#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
#import <QMapKit/QMapKit.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [QMapServices sharedServices].APIKey = @"YOUR KEY HERE";
    [GeneratedPluginRegistrant registerWithRegistry:self];
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end

Or in your swift code, specify your API key in the application delegate ios/Runner/AppDelegate.swift:

import UIKit
import Flutter
import QMapKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    QMapServices.shared().apiKey = "YOUR KEY HERE"
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

All #

  • You can now add a TencentMap widget to your widget tree. The TencentMap widget should be used within a widget with a bounded size. Using it in an unbounded widget will cause the application to throw a Flutter exception.
  • Note: You have to agree privacy before build TencentMap by calling TencentMap.agreePrivacy().

Sample Usage #

class MapTypesPage extends StatefulWidget {
  const MapTypesPage({Key? key}) : super(key: key);

  static const title = 'tecenc_map_example';

  @override
  State<MapTypesPage> createState() => _MapTypesPageState();
}

class _MapTypesPageState extends State<MapTypesPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(MapTypesPage.title),
      ),
      body: TencentMap(),
    );
  }
}

See the example directory for a complete sample app.

2
likes
150
pub points
55%
popularity

Publisher

unverified uploader

A Flutter plugin that integrated Tencent Map SDK, support Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, latlong2, stream_transform

More

Packages that depend on tencent_map_flutter