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

[google_maps_flutter] Add methods to programmatically show/hide marker's infowindow #2181

Merged
merged 9 commits into from
Feb 13, 2020

Conversation

giancarlopro
Copy link
Contributor

@giancarlopro giancarlopro commented Oct 11, 2019

Description

I needed to programmatically show marker's infowindow when a user tapped a polyline, so i've implemented those method and i'm currently using them and trying to maintain my repo current with this one.

I want a opinion on this implementation, because i don't think it's the optimal. I've tried to use a method channel for each Marker so i would be able to call marker.showInfoWindow(), but i can't create method channel's on the fly.

Related Issues

flutter/flutter#29899
flutter/flutter#33481
flutter/flutter#19647

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@giancarlopro
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@sh0umik
Copy link

sh0umik commented Nov 17, 2019

Any updates on Merging this pull request ?

@giancarlopro giancarlopro changed the title [google_maps_flutter] [WIP] Add methods to programmatically show/hide marker's infowindow [google_maps_flutter] Add methods to programmatically show/hide marker's infowindow Dec 16, 2019
@giancarlopro giancarlopro marked this pull request as ready for review December 16, 2019 17:03
Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for sending this PR. It overall looks great! I did a first round of review and left some comments.
We would also need tests before we can land this.

@giancarlopro
Copy link
Contributor Author

Thanks for the review @cyanglaz, i've been busy lately but soon i'll get back to this

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update the CHANGELOG and pubspec with a new version. Thanks!!

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@LukaszKrolicki
Copy link

I am able to show only one infowindow at a time. Is there a way to show all infowidnows?

@giancarlopro giancarlopro deleted the development branch June 28, 2021 14:58
@giancarlopro
Copy link
Contributor Author

I am able to show only one infowindow at a time. Is there a way to show all infowidnows?

@SenseiBunny only one info window is displayed at a time as stated in the google documentation

@Rhyanz46
Copy link

I want to show multiple infoWindow in one map and in one time, how to do that?

in javascript I can do this :

function initMap() {
  const uluru = { lat: -25.363, lng: 131.044 };
  const map = new google.maps.Map(document.getElementById("map"), {
    zoom: 4,
    center: uluru,
  });
  
  const infowindowA = new google.maps.InfoWindow({
    content: "a",
  });
  
  const infowindowB = new google.maps.InfoWindow({
    content: "b",
  });
  
  
  const markerA = new google.maps.Marker({
    position: uluru,
    map,
    title: "A",
  });
  
  infowindowA.open({
  	anchor: markerA,
    map,
    shouldFocus: false,
  });
  
  
  const markerB = new google.maps.Marker({
    position: {lat: -22.925286, lng: 139.912982},
    map,
    title: "B",
  });
  
  infowindowB.open({
  	anchor: markerB,
    map,
    shouldFocus: false,
  });
}

I see in flutter to show the infoWindow we should do something like this :

GoogleMapsFlutterPlatform.instance.showMarkerInfoWindow(MarkerId("0"), mapId: controller.mapId);
// or
mapController.showMarkerInfoWindow(MarkerId("0"));

but if I do showMarkerInfoWindow twice It's still show just one infoWindow

for full code i want to this :
image

can I do something like this in flutter ?

@Pokpa-max
Copy link

merci vraiment pour laide ,mon probleme est resolu

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants