Forráskód Böngészése

7.30 高德定位测试

huxiaoqiang 4 éve
szülő
commit
d42b5c1601
2 módosított fájl, 16 hozzáadás és 20 törlés
  1. 1 1
      lib/paegs/home_page/home_page.dart
  2. 15 19
      lib/paegs/map_demo/map_demo_page.dart

+ 1 - 1
lib/paegs/home_page/home_page.dart

@@ -370,7 +370,7 @@ class _HomePageState extends State<HomePage>
                   return netImgs.length == 0
                       ? GestureDetector(
                     onTap: (){
-                      MyTools().toPage(context, MapDemoPage(), (then){});
+                      // MyTools().toPage(context, MapDemoPage(), (then){});
                     },
                         child: Image.asset(
                             "${imgs[index]}",

+ 15 - 19
lib/paegs/map_demo/map_demo_page.dart

@@ -42,6 +42,7 @@ class _MapDemoPageState extends State<MapDemoPage> {
       onMapCreated: onMapCreated,
       rotateGesturesEnabled: false,
       touchPoiEnabled: true,
+      tiltGesturesEnabled: false,
       onPoiTouched: _onPoiTouched,
       myLocationStyleOptions: MyLocationStyleOptions(
         true,
@@ -78,11 +79,10 @@ class _MapDemoPageState extends State<MapDemoPage> {
                                 focusedBorder: InputBorder.none,
                                 hintText: '请输入地址',
                                 hintStyle: TextStyle(
-                                    color: MyColors.c999999,
-                                    fontSize: 16),
+                                    color: MyColors.c999999, fontSize: 16),
                                 isDense: true,
-                                contentPadding: const EdgeInsets.fromLTRB(
-                                    14, 4.5, 8, 4.5)),
+                                contentPadding:
+                                    const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5)),
                             maxLines: 1,
                             style: TextStyle(
                                 color: MyColors.c333333,
@@ -111,7 +111,7 @@ class _MapDemoPageState extends State<MapDemoPage> {
                     ],
                   ),
                   color: Colors.white,
-                  margin: EdgeInsets.symmetric(horizontal: 15,vertical: 30),
+                  margin: EdgeInsets.symmetric(horizontal: 15, vertical: 30),
                 )
               ],
             ),
@@ -169,12 +169,10 @@ class _MapDemoPageState extends State<MapDemoPage> {
   }
 
   void inquirePOI() {
-    Dio()
-        .get(
-            'https://restapi.amap.com/v3/place/text?keywords=${_controller.text.toString()}&city=${MyCookie().location.city}&output=json&offset=25&page=1&key=5dcd9f0ed7d51aefb5b2f73dba1069cb&extensions=all')
-        .then((value) {
-      print(
-          'https://restapi.amap.com/v3/place/text?keywords=${_controller.text.toString()}&city=${MyCookie().location.city}&output=json&offset=25&page=1&key=5dcd9f0ed7d51aefb5b2f73dba1069cb&extensions=all');
+     String v1 =
+        'https://restapi.amap.com/v3/place/text?keywords=${_controller.text.toString()}&city=${MyCookie().location.city}&output=json&offset=25&page=1&key=5dcd9f0ed7d51aefb5b2f73dba1069cb&extensions=all';
+    print(v1);
+    Dio().get(v1).then((value) {
       print(value);
       PoiBeanEntity entity =
           PoiBeanEntity().fromJson(json.decode(value.toString()));
@@ -185,13 +183,11 @@ class _MapDemoPageState extends State<MapDemoPage> {
               double.parse(element.location.split(',')[0])),
           icon: BitmapDescriptor.fromIconPath('images/地址.png'),
           infoWindow: InfoWindow(title: element.name),
-          // onTap: (markerId) {
-          //   print(markerId);
-          //   MapUtil.gotoAMap(double.parse(element.location.split(',')[0]),
-          //       double.parse(element.location.split(',')[1]));
-          // },
-          // onDragEnd: (markerId, endPosition) =>
-          //     _onMarkerDragEnd(markerId, endPosition),
+          onTap: (markerId) {
+            print(markerId);
+            MapUtil.gotoAMap(double.parse(element.location.split(',')[0]),
+                double.parse(element.location.split(',')[1]));
+          },
         );
       });
       setState(() {
@@ -202,7 +198,7 @@ class _MapDemoPageState extends State<MapDemoPage> {
                 double.parse(entity.pois[0].location.split(',')[0])),
             zoom: 18,
           )));
-        }else{
+        } else {
           showToast('未搜索到你查找的地点');
         }
       });