xbr_gaode_search 1.0.3
xbr_gaode_search: ^1.0.3 copied to clipboard
A new Flutter Plugin.
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.init(iosAppKey: "6576199a6c246345e57fee50d2edc8d1",androidAppKey: "");
}
void search(){
//初始化;主要针对IOS androidAppKey需在清单文件设置
XbrAmapSearch.init(iosAppKey: "6576199a6c246345e57fee50d2edc8d1",androidAppKey: "");
//关键词查询 返回大列表
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:MODE.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:MODE.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(26.638016, 106.795478),MLatLng(26.556585, 106.768857)]"),onPressed: (){
XbrAmapSearch.routeSearch(wayPoints:[MLatLng(26.638016, 106.795478),MLatLng(26.556585, 106.768857)],drivingMode:MODE.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:MODE.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),
)
],
),
),
);
}
}