Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@jan1za
Copy link

@jan1za jan1za commented Jan 27, 2019

Google Maps Flutter plugin feature addition.

  • Added polylines
  • Added tap event listener
  • Added long tap event listener
  • Added tap my location listener
  • Added tap my location button listener
  • Added enable or disable my location button

Polylines have been added to both iOS and Android, however iOS lacks styles and patterns, the feature is not available in the iOS version of google maps.

Example application extended to include:

  • Map UI example shows tap and long tap events.
  • Additional page that shows how to use Polylines.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot
Copy link

CLAs look good, thanks!

@awazgyawali
Copy link
Contributor

Great, a PR was already present here #1049. Either way, I have added further supports like polygon and map tap. Whichever gets accepted, I will make sure it will blend in.

@jan1za
Copy link
Author

jan1za commented Jan 29, 2019

@awazgyawali I saw call 1049 after I had submitted, if I had only looked sooner. I needed the lines for a project. Let's see what gets accepted. Thank you for the polygon support.

@jan1za jan1za changed the title Polylines added to Google Maps Flutter plugin Polylines, Map Tap, Map Long Tap added to Google Maps Flutter plugin Feb 1, 2019
@hayahyts
Copy link

hayahyts commented Feb 4, 2019

How do we use this?

@jan1za
Copy link
Author

jan1za commented Feb 4, 2019

@awazgyawali either wait for this branch to be merged into the baseline or clone my master repo.

Copy the packages/google_maps_flutter folder to the same level as your flutter app for example:

- workspace
 |_myflutterapp
   |_lib
   |_android
   |_ios
   |_pubspec.yaml
 |_google_maps_flutter

Then change your dependencies to point to this version and not the official version i.e. in your pubspec.yaml file change it to:

dev_dependencies:
  flutter_test:
    sdk: flutter

  google_maps_flutter:
    path: ../google_maps_flutter

Then follow the instructions on the google flutter library

Checkout the example app to see how to use polylines and taps.

@hayahyts
Copy link

hayahyts commented Feb 8, 2019

@awazgyawali either wait for this branch to be merged into the baseline or clone my master repo.

Copy the packages/google_maps_flutter folder to the same level as your flutter app for example:

- workspace
 |_myflutterapp
   |_lib
   |_android
   |_ios
   |_pubspec.yaml
 |_google_maps_flutter

Then change your dependencies to point to this version and not the official version i.e. in your pubspec.yaml file change it to:

dev_dependencies:
  flutter_test:
    sdk: flutter

  google_maps_flutter:
    path: ../google_maps_flutter

Then follow the instructions on the google flutter library

Checkout the example app to see how to use polylines and taps.

Thank you

@tolotrasamuel
Copy link

Why is this not merged yet ?

@jan1za
Copy link
Author

jan1za commented Feb 11, 2019

Hi @nandymandy1

Create a handler

When the map is created add the long tapped and marker tapped handlers:

 void _onMapLongTapped(LatLng location) {
     print('tapped');
     // add place marker code here
}
// Add an event for the map created
void _onMapCreated(GoogleMapController controller) {
    setState(() {
      mapController = controller;
      mapController.onMapLongTapped.add(_onMapLongTapped);
      mapController.onMapTapped.add(_onMapTapped);
}     

Create your map widget, adding the event handler for map created:

 return GoogleMap(
      onMapCreated: _onMapCreated,
      ....

This should display the map and print a message each time a long press occurs
Now add the add marker feature

Call this method from the long tapped method to add the marker. (Don't forget to define Marker _myMarker)

Future<void> _addMyMarker(LatLng location) async {
    if (_myMarker != null) {
      mapController.updateMarker(
        _myMarker,
        MarkerOptions(
            position: LatLng(
          location.latitude,
          location.longitude,
        )),
      );
    } else {
      _myMarker = await mapController.addMarker(
        MarkerOptions(
          position: LatLng(
            location.latitude,
            location.longitude,
          ),
        ),
      );
    }
  }

@isaachjk
Copy link

just waiting 4 this

@joaquinperaza
Copy link

iOS my location button not working could be because using this branch?

@jan1za jan1za requested review from amirh and iskakaushik as code owners April 5, 2019 11:25
@jan1za
Copy link
Author

jan1za commented Apr 5, 2019

@mattl-nz :) it's fixed. Thank you for your patience. I refactored my code, and now it works the same way as Markers. The changes are breaking changes. See the example code to see how to implement it.

@jan1za
Copy link
Author

jan1za commented Apr 5, 2019

@iskakaushik @amirh I have refactored the code to work in the same way Marker does, please could you merge this pull request into master.

@iskakaushik
Copy link
Contributor

Hi @jan1za , firstly, thanks for your contribution. That's a lot of features :-)

To make it easier for me to review could you break up your PR into smaller separate pull requests:

  1. Long tap events.
  2. Polylines: There's a PR that is pretty close to done. [google_maps_flutter] Widget based polyline support for google maps. #1049, if you think it's missing some features, or if you do not agree with parts of it, could you please comment on that.
  3. Tap events for maps merged yesterday: [google_maps_flutter]add support for map tapping #985, so we might not need it.

Could you explain what the following features are?

  • Added tap my location listener
  • Added tap my location button listener
  • Added enable or disable my location button

It might also make sense to do them as a different PR.

@jan1za
Copy link
Author

jan1za commented Apr 8, 2019

@iskakaushik I will break it apart into multiple pull requests.

  • Long tap events.

  • Polylines: There's a PR that is pretty close to done. [google_maps_flutter] Widget based polyline support for google maps. #1049, if you think it's missing some features, or if you do not agree with parts of it, could you please comment on that. cool

  • Tap events for maps merged yesterday: [google_maps_flutter]add support for map tapping #985, so we might not need it. I saw that, removed my version and merged with [google_maps_flutter]add support for map tapping #985

  • Added tap my location listener Event when tapping on the my location blue dot

  • Added tap my location button listener Intercepts when someone taps on the my location button, this button shows your location, and centers the screen on your location. This feature just intercepts that, so that you can perform additional functionality, like so a popup etc

  • Added enable or disable my location button in my case I wanted to plot the users position on the screen, but I wanted my own button that shows the users position. Enabling my location, shows your location but also shows the my location button, I wanted to disable that and therefor add this feature

@iskakaushik iskakaushik closed this May 1, 2019
@MRL-00
Copy link

MRL-00 commented May 6, 2019

@jan1za Where is the PR for the long tap events? Is that being merged into Google Maps Flutter?

@MRL-00
Copy link

MRL-00 commented Jun 26, 2019

Hi all

Does anyone know how to get the long taps working with Google Maps Flutter?

@mrzuliann
Copy link

I'm using mapbox on flutter with flutter_map package and need to add marker on map when tapped on map and then get marker lat and long to send to server. How get it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.