xbr_gaode_search 5.0.0 copy "xbr_gaode_search: ^5.0.0" to clipboard
xbr_gaode_search: ^5.0.0 copied to clipboard

小镖人高德地图查询插件 xbr_gaode_search

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:xbr_gaode_search/core/lat_lng.dart';
import 'package:xbr_gaode_search/core/driving_mode.dart';
import 'package:xbr_gaode_search/core/truck.dart';
import 'package:xbr_gaode_search/xbr_gaode_search.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    XbrAmapSearch.initKey(iosAppKey: "6576199a6c246345e57fee50d2edc8d1",androidAppKey: "1213b63891844954a97511708731ff12");
    XbrAmapSearch.updatePrivacyShow(hasShow:true,hasContains: true);
    XbrAmapSearch.updatePrivacyAgree(hasAgree: true);
  }

  void search(){
    //初始化;主要针对IOS androidAppKey需在清单文件设置
    XbrAmapSearch.initKey(iosAppKey: "6576199a6c246345e57fee50d2edc8d1",androidAppKey: "1213b63891844954a97511708731ff12");
    //关键词查询 返回大列表
    XbrAmapSearch.keywordsSearch( keyWord:"天安门", cityCode:"", page : 1, limit : 10, back:(code,data){});
    //输入提示 返回最近几条数据,cityLimit 是否限制在当前城市
    XbrAmapSearch.inputTips( newText:"天安门", city:"北京", cityLimit : false, back:(code,data){});
    //通过Id查询详情,通过关键词查询/输入提示会返回POI-id
    XbrAmapSearch.getPOIById( id:"h0000", back:(code,data){});
    //线路规划 wayPoints:点集合,支持最大18个点(起点+终点+16个途径点),drivingMode:偏好
    XbrAmapSearch.routeSearch(wayPoints:[MLatLng(26.638016, 106.795478),MLatLng(26.556585, 106.768857)],drivingMode:DrivingMode.DRIVING_SINGLE_DEFAULT, back:(code,data){});
    //货车线路规划 wayPoints:点集合,支持最大18个点(起点+终点+16个途径点),drivingMode:偏好,truckInfo:车辆信息
    XbrAmapSearch.truckRouteSearch(
      wayPoints:[MLatLng(26.638016, 106.795478),MLatLng(26.556585, 106.768857)],
      drivingMode:DrivingMode.DRIVING_SINGLE_DEFAULT,
      truckInfo:TruckInfo(plateProvince: "京",plateNumber: "A85A84",truckAxis: 4,truckHeight: 2.5,truckLoad: 4.2),
      back:(code,data){},
    );
    //地理编码
    XbrAmapSearch.geocoding(address: "贵阳双龙数据工厂",back:(code,data){});
    //逆地理编码
    XbrAmapSearch.reGeocoding(point: MLatLng(26.556585, 106.768857),back:(code,data){});
  }

  String text = "点击功能返回结果";
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('请在地图plugin测试'),
        ),
        body:Column(
          children: [
            ElevatedButton( child: Text("关键词查询:天安门"),onPressed: (){
              XbrAmapSearch.keywordsSearch( keyWord:"天安门", cityCode:"", page : 1, limit : 10, back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            ElevatedButton( child: Text("POI详情:BV10006499"),onPressed: (){
              XbrAmapSearch.getPOIById( id:"BV10006499", back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            ElevatedButton( child: Text("输入提示:天安"),onPressed: (){
              XbrAmapSearch.inputTips( newText:"天安", city:"北京", cityLimit : false, back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            ElevatedButton( child: Text("线路规划:[MLatLng(45.807283, 126.568021),MLatLng(22.793247, 100.947589)]"),onPressed: (){
              XbrAmapSearch.routeSearch(wayPoints:[MLatLng(45.807283, 126.568021),MLatLng(22.793247, 100.947589)],drivingMode:DrivingMode.DRIVING_SINGLE_DEFAULT, back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            ElevatedButton( child: Text("货车线路规划:[MLatLng(45.807283, 126.568021),MLatLng(22.793247, 100.947589)]"),onPressed: (){
              XbrAmapSearch.truckRouteSearch(truckInfo:TruckInfo(
                  plateProvince:"贵",
                  plateNumber:"AB5158",
                  truckAxis:2.0,
                  truckHeight: 2.4,
                  truckWidth:2.6,
                  truckLoad: 3.2,
                  truckWeight: 4.6
              ),wayPoints:[MLatLng(45.807283, 126.568021),MLatLng(22.793247, 100.947589)],drivingMode:DrivingMode.DRIVING_SINGLE_DEFAULT, back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            ElevatedButton( child: Text("线路规划(多点):[MLatLng(26.638016, 106.795478),MLatLng(26.630416, 106.765305),MLatLng(26.556585, 106.768857)]"),onPressed: (){
              XbrAmapSearch.routeSearch(wayPoints:[MLatLng(26.638016, 106.795478),MLatLng(26.630416, 106.765305),MLatLng(26.556585, 106.768857)],drivingMode:DrivingMode.DRIVING_SINGLE_DEFAULT, back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            ElevatedButton( child: Text("地理编码:贵阳双龙数据工厂"),onPressed: (){
              XbrAmapSearch.geocoding(address: "贵阳双龙数据工厂",back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            ElevatedButton( child: Text("逆地理编码:MLatLng(26.556585, 106.768857)"),onPressed: (){
              XbrAmapSearch.reGeocoding(point: MLatLng(26.556585, 106.768857),back:(code,data){
                setState(() {
                  text = json.encode(data);
                  debugPrint(text);
                });
              });
            }),
            Card(
              child: Text(text),
            )
          ],
        ),
      ),
    );
  }
}
0
likes
115
pub points
41%
popularity

Publisher

unverified uploader

小镖人高德地图查询插件 xbr_gaode_search

Documentation

API reference

License

MulanPSL-2.0 (license)

Dependencies

flutter

More

Packages that depend on xbr_gaode_search