🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / FLUTTER / Google Maps Uygulamasına yönlerdime latitude ve longitude no api key

1-) FLUTTER - Google Maps Uygulamasına yönlerdime latitude ve longitude no api key

 

 

1. adım -> flutter pub add url_launcher  -> bu paketi kur

 

 

ElevatedButton(
  onPressed:
_launchMap,
  child:
Text('Adresi Google Haritalar\'da Aç'),
),

 

final double latitude = 11.012072;
final double longitude = 18.968116;

Future<void> _launchMap() async {
  
String url = 'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
    
if (!await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication)) {
      
throw 'Could not launch $url';
    }
}

 

 

 

 

 

2. ADIM İOS İÇİN YÖNLENDİRME SON KOD
https://pub.dev/packages/map_launcher

 


Future<void> _launchMap(String url) async {
  


  
if(Platform.isIOS){
    
final availableMaps = await MapLauncher.installedMaps;
    print(
availableMaps); // [AvailableMap { mapName: Google Maps, mapType: google }, ...]

    
await availableMaps.first.showMarker(
      coords:
Coords(20.98398114543243, 18.67110493110574),
      title:
"Trendyol",
    );

  }
else{

    
if (!await launchUrl(Uri.parse(url),
        mode:
LaunchMode.externalApplication)) {
      
throw 'Could not launch $url';
    }

  }

}

 

 

 2024 Nisan 25 Perşembe
 341