byn_tencent_map 0.1.4 copy "byn_tencent_map: ^0.1.4" to clipboard
byn_tencent_map: ^0.1.4 copied to clipboard

A Flutter plugin for integrating Tencent Maps in iOS and Android applications

example/lib/main.dart

import 'dart:io';

import 'package:byn_tencent_map/byn_tencent_map.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';

void main() {

  if (Platform.isIOS) {
    TencentMap.initIOSSdk("K7LBZ-6OXKZ-YHIXM-7K5IR-LU4T7-UDFH4");
  }

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();

  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> fetchLocation() async {
    MapPoiData? location;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      location = await TencentMap.getLocation();
    } on PlatformException {
    }
    print("location ---- ${location?.toJson()}");
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        resizeToAvoidBottomInset: false,
        appBar: AppBar(
          title: const Text('Plugin example app'),
          actions: [
            IconButton(
              onPressed: () {
                fetchLocation();
              },
              icon: const Icon(Icons.location_on_outlined),
            ),
          ],
        ),
        body:
        TencentMapView(
          onPick: (data) {
            print("demo onPick ---- ${data.toJson()}");
          },
        ),
        // body: Column(
        //   children: [
        //
        //   ],
        // ),
      ),
    );
  }
}
1
likes
125
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for integrating Tencent Maps in iOS and Android applications

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on byn_tencent_map