Ja som vytvoriť aplikáciu, Chvenie, ktoré používa geografického kódovania plugin s cieľom previesť LatLng pozíciu na adresu.
Tu môj kód:
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'),
),
],
),
]),
));
}
}
Výsledkom prepočtu sa líši medzi iOS a Android verzia, napríklad:
LatLng = 45.478981,9.207120
iOS verzia výsledok: "Via Alessandro Tadino 21"
Android verzia výsledok: "46"
Nechápem, prečo je to odlišné, mal by som použiť iný plugin? Snáď plugin používa dve rôzne technológie pre iOS a Android. Robí Android použiť druhu na Google Maps plugin?