วิธีที่จะแปลง LatLng เพื่อที่อยู่ของกระพือภาพ(ทั้งสอง iOS และ Android เวอร์ชั่น)

0

คำถาม

ฉันกำลังสร้างโปรแกรกับกระพือภาพที่ใช้ geocoding โปรแกรมเสริม เพื่อที่จะแปลง LatLng ตำแหน่งที่จะอยู่แล้ว

นี่ของรหัส:

import 'package:geocoding/geocoding.dart';

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

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  late String location = "location name";

  Future<String> getAddress() async {
    List<Placemark> placemarks = await placemarkFromCoordinates(
        45.478981,9.207120,
        localeIdentifier: 'it_It');
    return placemarks[0].name.toString();
  }

  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text("Convert LatLng to Address")),
        body: Center(
          child: Stack(children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(location),
                ElevatedButton(
                  onPressed: () {
                    getAddress().then((value) => {
                          setState(() {
                            location = value;
                          }),
                          print(value)
                        });
                  },
                  child: const Text('Convert LatLng'),
                ),
              ],
            ),
          ]),
        ));
  }
}

ผลของการแปลงนั้นมักแตกต่างระหว่าง iOS และ Android เวอร์ชั่นสำหรับตัวอย่าง:

LatLng = 45.478981,9.207120

iOS รุ่นของผล: "ผ่านทาง Alessandro Tadino 21"

Android รุ่นของผล: "46"

ฉันไม่เข้าใจว่าทำไมมันแตกต่าง,ฉันควรจะใช้ส่วนเสริมอีก? บางทีอาจจะที่โปรแกรมเสริมใช้สองคนแตกต่างเทคโนโลยีเพื่อ iOS และ Android. ทำ Android ใช้แบบของกูเกิ้ลแผนที่ส่วนเสริม?

dart flutter geocoder geocoding
2021-11-19 15:26:47
1

คำตอบที่ดีที่สุด

1

สิ่งที่คุณต้องการคือย้อนกลับ geocoding

ย้อนกลับ geocoding คือโพรเซสของการเปลี่ยนแปล geographic พิกัดเข้าที่คนอ่านอยู่

ตั้งแต่คุณต้องการแบบเดียวกันแสดงผลทั้งสอ android และ iOS อุปกรณ์ผมขอแนะนำให้คุณใช้ กูเกิ้ล Geocoding รูปแบบ api

งั้นคุณสามารถใช้รูปแบบ api กุญแจกับ google_geocoding แพกเกจและกที่ใช้พิกัด

var googleGeocoding = GoogleGeocoding("API-KEY");
var result = await googleGeocoding.geocoding.getReverse(LatLon(40.714224,-73.961452));
2021-11-19 18:45:20

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่