Flutter get coordinates from google maps












1















I use the package google_maps_flutter to use Google maps in my app. My problem is how to set a listener, show when I press in the map to get the coordination of this place. I don't find anything in documentation.
The only thing which I find is with controllerMap, which I use to set marker listener, is that it has a method,
.addListener(listener)



Any idea?










share|improve this question























  • github.com/flutter/plugins/tree/master/packages/… You should look through the examples. The plugin is in alpha. Here is the how to add on tap listener

    – user1462442
    Nov 20 '18 at 17:14











  • I have seen it but I didn't find anything relevant. Can you be more specific? The only tap thing which I find and I use is the onMarkerTapped

    – Filippos Ser
    Nov 20 '18 at 17:17













  • If its not there then, it is probably not implemented github.com/flutter/plugins/blob/… GoogleMapController has very little features at the moment. The plugin is in alpha

    – user1462442
    Nov 20 '18 at 17:35
















1















I use the package google_maps_flutter to use Google maps in my app. My problem is how to set a listener, show when I press in the map to get the coordination of this place. I don't find anything in documentation.
The only thing which I find is with controllerMap, which I use to set marker listener, is that it has a method,
.addListener(listener)



Any idea?










share|improve this question























  • github.com/flutter/plugins/tree/master/packages/… You should look through the examples. The plugin is in alpha. Here is the how to add on tap listener

    – user1462442
    Nov 20 '18 at 17:14











  • I have seen it but I didn't find anything relevant. Can you be more specific? The only tap thing which I find and I use is the onMarkerTapped

    – Filippos Ser
    Nov 20 '18 at 17:17













  • If its not there then, it is probably not implemented github.com/flutter/plugins/blob/… GoogleMapController has very little features at the moment. The plugin is in alpha

    – user1462442
    Nov 20 '18 at 17:35














1












1








1








I use the package google_maps_flutter to use Google maps in my app. My problem is how to set a listener, show when I press in the map to get the coordination of this place. I don't find anything in documentation.
The only thing which I find is with controllerMap, which I use to set marker listener, is that it has a method,
.addListener(listener)



Any idea?










share|improve this question














I use the package google_maps_flutter to use Google maps in my app. My problem is how to set a listener, show when I press in the map to get the coordination of this place. I don't find anything in documentation.
The only thing which I find is with controllerMap, which I use to set marker listener, is that it has a method,
.addListener(listener)



Any idea?







google-maps dart flutter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 16:53









Filippos SerFilippos Ser

119111




119111













  • github.com/flutter/plugins/tree/master/packages/… You should look through the examples. The plugin is in alpha. Here is the how to add on tap listener

    – user1462442
    Nov 20 '18 at 17:14











  • I have seen it but I didn't find anything relevant. Can you be more specific? The only tap thing which I find and I use is the onMarkerTapped

    – Filippos Ser
    Nov 20 '18 at 17:17













  • If its not there then, it is probably not implemented github.com/flutter/plugins/blob/… GoogleMapController has very little features at the moment. The plugin is in alpha

    – user1462442
    Nov 20 '18 at 17:35



















  • github.com/flutter/plugins/tree/master/packages/… You should look through the examples. The plugin is in alpha. Here is the how to add on tap listener

    – user1462442
    Nov 20 '18 at 17:14











  • I have seen it but I didn't find anything relevant. Can you be more specific? The only tap thing which I find and I use is the onMarkerTapped

    – Filippos Ser
    Nov 20 '18 at 17:17













  • If its not there then, it is probably not implemented github.com/flutter/plugins/blob/… GoogleMapController has very little features at the moment. The plugin is in alpha

    – user1462442
    Nov 20 '18 at 17:35

















github.com/flutter/plugins/tree/master/packages/… You should look through the examples. The plugin is in alpha. Here is the how to add on tap listener

– user1462442
Nov 20 '18 at 17:14





github.com/flutter/plugins/tree/master/packages/… You should look through the examples. The plugin is in alpha. Here is the how to add on tap listener

– user1462442
Nov 20 '18 at 17:14













I have seen it but I didn't find anything relevant. Can you be more specific? The only tap thing which I find and I use is the onMarkerTapped

– Filippos Ser
Nov 20 '18 at 17:17







I have seen it but I didn't find anything relevant. Can you be more specific? The only tap thing which I find and I use is the onMarkerTapped

– Filippos Ser
Nov 20 '18 at 17:17















If its not there then, it is probably not implemented github.com/flutter/plugins/blob/… GoogleMapController has very little features at the moment. The plugin is in alpha

– user1462442
Nov 20 '18 at 17:35





If its not there then, it is probably not implemented github.com/flutter/plugins/blob/… GoogleMapController has very little features at the moment. The plugin is in alpha

– user1462442
Nov 20 '18 at 17:35












3 Answers
3






active

oldest

votes


















2














I have solved the problem using the onMarkerTapped callback methods below:



Note: mapController below is an instance of the GoogleMap Controller



 mapController.**onMarkerTapped**.add((marker){

String title= marker.options.infoWindowText.title;
String latitude= marker.options.position.latitude.toString();
String longitude= marker.options.position.longitude.toString();

});





share|improve this answer

































    1














    google map plugin has a lot of errors:), I prefer using this plugin : flutter_map



    full example :



    import 'package:location/location.dart';
    import 'package:flutter_map/flutter_map.dart';
    import 'package:latlong/latlong.dart';

    class ContactPage extends StatefulWidget {
    @override
    ContactPageState createState() => new ContactPageState();
    }

    class ContactPageState extends State<ContactPage>
    with TickerProviderStateMixin {


    static LatLng myLocation = new LatLng(51.5, -0.09);
    @override
    void initState() {
    super.initState();
    setState(() {
    new LatLng(51.5, -0.09);
    });
    }

    @override
    Widget build(BuildContext context) {
    Size screenSize = MediaQuery.of(context).size;
    double heigh = screenSize.height;
    TextStyle whiteStyle = new TextStyle(fontSize: 20.0, color: Colors.white);
    return new Directionality(
    textDirection: TextDirection.rtl,
    child: new Container(
    padding: new EdgeInsets.only(bottom: 10.0, left: 1.0, right: 1.0),
    color: Colors.white,
    child: new FlutterMap(
    options: new MapOptions(
    center: myLocation,
    zoom: 15.0,
    maxZoom: 15.0,
    minZoom: 3.0,
    onTap: _handleTap),
    layers: [
    new TileLayerOptions(
    urlTemplate:
    "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
    subdomains: ['a', 'b', 'c']),
    new MarkerLayerOptions(markers: markers)
    ],
    )
    )),
    );
    }
    _handleTap(LatLng point) {
    setState(() {
    myLocation = point;
    });
    }
    }





    share|improve this answer































      1














      This functionality is currently not available in version 2.0 of the google flutter plugin, however there are two pull requests that have added this functionality.




      • 1121

      • 941


      Pull request 1121 has example code on how to use the tap functionality.






      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397826%2fflutter-get-coordinates-from-google-maps%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        2














        I have solved the problem using the onMarkerTapped callback methods below:



        Note: mapController below is an instance of the GoogleMap Controller



         mapController.**onMarkerTapped**.add((marker){

        String title= marker.options.infoWindowText.title;
        String latitude= marker.options.position.latitude.toString();
        String longitude= marker.options.position.longitude.toString();

        });





        share|improve this answer






























          2














          I have solved the problem using the onMarkerTapped callback methods below:



          Note: mapController below is an instance of the GoogleMap Controller



           mapController.**onMarkerTapped**.add((marker){

          String title= marker.options.infoWindowText.title;
          String latitude= marker.options.position.latitude.toString();
          String longitude= marker.options.position.longitude.toString();

          });





          share|improve this answer




























            2












            2








            2







            I have solved the problem using the onMarkerTapped callback methods below:



            Note: mapController below is an instance of the GoogleMap Controller



             mapController.**onMarkerTapped**.add((marker){

            String title= marker.options.infoWindowText.title;
            String latitude= marker.options.position.latitude.toString();
            String longitude= marker.options.position.longitude.toString();

            });





            share|improve this answer















            I have solved the problem using the onMarkerTapped callback methods below:



            Note: mapController below is an instance of the GoogleMap Controller



             mapController.**onMarkerTapped**.add((marker){

            String title= marker.options.infoWindowText.title;
            String latitude= marker.options.position.latitude.toString();
            String longitude= marker.options.position.longitude.toString();

            });






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 24 '18 at 8:26









            Pradeep

            8,254101930




            8,254101930










            answered Dec 24 '18 at 8:06









            lionelsanoulionelsanou

            314




            314

























                1














                google map plugin has a lot of errors:), I prefer using this plugin : flutter_map



                full example :



                import 'package:location/location.dart';
                import 'package:flutter_map/flutter_map.dart';
                import 'package:latlong/latlong.dart';

                class ContactPage extends StatefulWidget {
                @override
                ContactPageState createState() => new ContactPageState();
                }

                class ContactPageState extends State<ContactPage>
                with TickerProviderStateMixin {


                static LatLng myLocation = new LatLng(51.5, -0.09);
                @override
                void initState() {
                super.initState();
                setState(() {
                new LatLng(51.5, -0.09);
                });
                }

                @override
                Widget build(BuildContext context) {
                Size screenSize = MediaQuery.of(context).size;
                double heigh = screenSize.height;
                TextStyle whiteStyle = new TextStyle(fontSize: 20.0, color: Colors.white);
                return new Directionality(
                textDirection: TextDirection.rtl,
                child: new Container(
                padding: new EdgeInsets.only(bottom: 10.0, left: 1.0, right: 1.0),
                color: Colors.white,
                child: new FlutterMap(
                options: new MapOptions(
                center: myLocation,
                zoom: 15.0,
                maxZoom: 15.0,
                minZoom: 3.0,
                onTap: _handleTap),
                layers: [
                new TileLayerOptions(
                urlTemplate:
                "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                subdomains: ['a', 'b', 'c']),
                new MarkerLayerOptions(markers: markers)
                ],
                )
                )),
                );
                }
                _handleTap(LatLng point) {
                setState(() {
                myLocation = point;
                });
                }
                }





                share|improve this answer




























                  1














                  google map plugin has a lot of errors:), I prefer using this plugin : flutter_map



                  full example :



                  import 'package:location/location.dart';
                  import 'package:flutter_map/flutter_map.dart';
                  import 'package:latlong/latlong.dart';

                  class ContactPage extends StatefulWidget {
                  @override
                  ContactPageState createState() => new ContactPageState();
                  }

                  class ContactPageState extends State<ContactPage>
                  with TickerProviderStateMixin {


                  static LatLng myLocation = new LatLng(51.5, -0.09);
                  @override
                  void initState() {
                  super.initState();
                  setState(() {
                  new LatLng(51.5, -0.09);
                  });
                  }

                  @override
                  Widget build(BuildContext context) {
                  Size screenSize = MediaQuery.of(context).size;
                  double heigh = screenSize.height;
                  TextStyle whiteStyle = new TextStyle(fontSize: 20.0, color: Colors.white);
                  return new Directionality(
                  textDirection: TextDirection.rtl,
                  child: new Container(
                  padding: new EdgeInsets.only(bottom: 10.0, left: 1.0, right: 1.0),
                  color: Colors.white,
                  child: new FlutterMap(
                  options: new MapOptions(
                  center: myLocation,
                  zoom: 15.0,
                  maxZoom: 15.0,
                  minZoom: 3.0,
                  onTap: _handleTap),
                  layers: [
                  new TileLayerOptions(
                  urlTemplate:
                  "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                  subdomains: ['a', 'b', 'c']),
                  new MarkerLayerOptions(markers: markers)
                  ],
                  )
                  )),
                  );
                  }
                  _handleTap(LatLng point) {
                  setState(() {
                  myLocation = point;
                  });
                  }
                  }





                  share|improve this answer


























                    1












                    1








                    1







                    google map plugin has a lot of errors:), I prefer using this plugin : flutter_map



                    full example :



                    import 'package:location/location.dart';
                    import 'package:flutter_map/flutter_map.dart';
                    import 'package:latlong/latlong.dart';

                    class ContactPage extends StatefulWidget {
                    @override
                    ContactPageState createState() => new ContactPageState();
                    }

                    class ContactPageState extends State<ContactPage>
                    with TickerProviderStateMixin {


                    static LatLng myLocation = new LatLng(51.5, -0.09);
                    @override
                    void initState() {
                    super.initState();
                    setState(() {
                    new LatLng(51.5, -0.09);
                    });
                    }

                    @override
                    Widget build(BuildContext context) {
                    Size screenSize = MediaQuery.of(context).size;
                    double heigh = screenSize.height;
                    TextStyle whiteStyle = new TextStyle(fontSize: 20.0, color: Colors.white);
                    return new Directionality(
                    textDirection: TextDirection.rtl,
                    child: new Container(
                    padding: new EdgeInsets.only(bottom: 10.0, left: 1.0, right: 1.0),
                    color: Colors.white,
                    child: new FlutterMap(
                    options: new MapOptions(
                    center: myLocation,
                    zoom: 15.0,
                    maxZoom: 15.0,
                    minZoom: 3.0,
                    onTap: _handleTap),
                    layers: [
                    new TileLayerOptions(
                    urlTemplate:
                    "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                    subdomains: ['a', 'b', 'c']),
                    new MarkerLayerOptions(markers: markers)
                    ],
                    )
                    )),
                    );
                    }
                    _handleTap(LatLng point) {
                    setState(() {
                    myLocation = point;
                    });
                    }
                    }





                    share|improve this answer













                    google map plugin has a lot of errors:), I prefer using this plugin : flutter_map



                    full example :



                    import 'package:location/location.dart';
                    import 'package:flutter_map/flutter_map.dart';
                    import 'package:latlong/latlong.dart';

                    class ContactPage extends StatefulWidget {
                    @override
                    ContactPageState createState() => new ContactPageState();
                    }

                    class ContactPageState extends State<ContactPage>
                    with TickerProviderStateMixin {


                    static LatLng myLocation = new LatLng(51.5, -0.09);
                    @override
                    void initState() {
                    super.initState();
                    setState(() {
                    new LatLng(51.5, -0.09);
                    });
                    }

                    @override
                    Widget build(BuildContext context) {
                    Size screenSize = MediaQuery.of(context).size;
                    double heigh = screenSize.height;
                    TextStyle whiteStyle = new TextStyle(fontSize: 20.0, color: Colors.white);
                    return new Directionality(
                    textDirection: TextDirection.rtl,
                    child: new Container(
                    padding: new EdgeInsets.only(bottom: 10.0, left: 1.0, right: 1.0),
                    color: Colors.white,
                    child: new FlutterMap(
                    options: new MapOptions(
                    center: myLocation,
                    zoom: 15.0,
                    maxZoom: 15.0,
                    minZoom: 3.0,
                    onTap: _handleTap),
                    layers: [
                    new TileLayerOptions(
                    urlTemplate:
                    "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                    subdomains: ['a', 'b', 'c']),
                    new MarkerLayerOptions(markers: markers)
                    ],
                    )
                    )),
                    );
                    }
                    _handleTap(LatLng point) {
                    setState(() {
                    myLocation = point;
                    });
                    }
                    }






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 21 '18 at 3:12









                    Yousuf AL-MawaliYousuf AL-Mawali

                    786




                    786























                        1














                        This functionality is currently not available in version 2.0 of the google flutter plugin, however there are two pull requests that have added this functionality.




                        • 1121

                        • 941


                        Pull request 1121 has example code on how to use the tap functionality.






                        share|improve this answer




























                          1














                          This functionality is currently not available in version 2.0 of the google flutter plugin, however there are two pull requests that have added this functionality.




                          • 1121

                          • 941


                          Pull request 1121 has example code on how to use the tap functionality.






                          share|improve this answer


























                            1












                            1








                            1







                            This functionality is currently not available in version 2.0 of the google flutter plugin, however there are two pull requests that have added this functionality.




                            • 1121

                            • 941


                            Pull request 1121 has example code on how to use the tap functionality.






                            share|improve this answer













                            This functionality is currently not available in version 2.0 of the google flutter plugin, however there are two pull requests that have added this functionality.




                            • 1121

                            • 941


                            Pull request 1121 has example code on how to use the tap functionality.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 1 at 9:56









                            JasonJason

                            35239




                            35239






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397826%2fflutter-get-coordinates-from-google-maps%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                這個網誌中的熱門文章

                                Hercules Kyvelos

                                Tangent Lines Diagram Along Smooth Curve

                                Yusuf al-Mu'taman ibn Hud