title: Flutter URL Launcher Google Maps
body: <p><strong>List.dart</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:url_launcher/url_launcher.dart';
  
  class List extends StatefulWidget {
  
    @override
    ListState createState() {
      return new ListState();
    }
  }
  
  class ListState extends State&lt;List&gt; {
  
    static const double lat = 2.813812,  long = 101.503413;
    static const String map_api= "API_KEY";
  
    @override
    Widget build(BuildContext context) {
  
      //method to launch maps
      void launchMap() async{
        const url = "https://maps.google.com/maps/search/?api=$map_api&amp;query=$lat,$long";
        if (await canLaunch(url)) {
          print("Can launch");
          void initState(){
            super.initState();
  
            canLaunch( "https://maps.google.com/maps/search/?api=$map_api&amp;query=$lat,$long");
          }
  
          await launch(url);
        } else {
          print("Could not launch");
          throw 'Could not launch Maps';
        }
      }
  
      //method to bring out dialog
      void makeDialog(){
        showDialog(
            context: context,
            builder: (_) =&gt; new SimpleDialog(
              contentPadding: EdgeInsets.only(left: 30.0, top: 30.0),
              children: &lt;Widget&gt;[
                new Text("Address: ",
                  style: TextStyle(
                    fontWeight: FontWeight.bold
                  ),
                ),
                new ButtonBar(
                  children: &lt;Widget&gt;[
                    new IconButton(
                        icon: Icon(Icons.close),
                        onPressed: (){
                          Navigator.pop(context);
                        }
                        )
                  ],
                )
              ],
            )
        );
      }
  
      return new Scaffold(
        body: new ListView.builder(
            itemBuilder: (context, index) =&gt; ExpansionTile(
                title: new Text("State ${index+1}"),
                children: &lt;Widget&gt;[
                  new ListTile(
                    title: new Text("Place 1"),
                    trailing: new Row(
                      mainAxisSize: MainAxisSize.min,
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: &lt;Widget&gt;[
                        new IconButton(
                            icon: Icon(Icons.info),
                            onPressed: makeDialog
                        ),
                        new IconButton(
                            icon: Icon(Icons.directions),
                            onPressed: launchMap
                        )
                      ],
                    ),
                  ),
                  new Divider(height: 10.0),
                  new ListTile(
                    title: new Text("Place 2"),
                    trailing: new Row(
                      mainAxisSize: MainAxisSize.min,
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: &lt;Widget&gt;[
                        new IconButton(
                            icon: Icon(Icons.info),
                            onPressed: makeDialog
                        ),
                        new IconButton(
                            icon: Icon(Icons.directions),
                            onPressed: launchMap
                        )
                      ],
                    ),
                  )
                ],
            ),
          itemCount: 5,
        ),
      );
    }
  }
  </code></pre>
  
  <p>My project currently involves launching Google Maps from the URL launcher library. But the problem I am currently having is Google Maps will open but it does not open to the latitude and longitude that I have set as the variable.</p>
  
  <p>How do i set the URL for it to launch according to the coordinates? Or is there a better alternative?</p>
  
  <p>Please assist.</p>