-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_flutter] Polylines, Map Tap, Map Long Tap added to Google Maps Flutter plugin #1121
Conversation
|
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. |
|
CLAs look good, thanks! |
|
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. |
|
@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. |
|
How do we use this? |
|
@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: Then change your dependencies to point to this version and not the official version i.e. in your pubspec.yaml file change it to: Then follow the instructions on the google flutter library Checkout the example app to see how to use polylines and taps. |
Thank you |
|
Why is this not merged yet ? |
|
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 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,
),
),
);
}
}
|
|
just waiting 4 this |
|
iOS my location button not working could be because using this branch? |
|
@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. |
|
@iskakaushik @amirh I have refactored the code to work in the same way Marker does, please could you merge this pull request into master. |
|
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:
Could you explain what the following features are?
It might also make sense to do them as a different PR. |
|
@iskakaushik I will break it apart into multiple pull requests.
|
|
@jan1za Where is the PR for the long tap events? Is that being merged into Google Maps Flutter? |
|
Hi all Does anyone know how to get the long taps working with Google Maps Flutter? |
|
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? |
Google Maps Flutter plugin feature addition.
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: