Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Info windo #15

Open
mohamed6996 opened this issue Sep 24, 2019 · 2 comments
Open

Custom Info windo #15

mohamed6996 opened this issue Sep 24, 2019 · 2 comments

Comments

@mohamed6996
Copy link

Currently, info window displays the title as count id. I need to to display q custom title.

@felpsio
Copy link

felpsio commented Sep 27, 2019

ugly workaround:

  updateMarkers(Set<Marker> markers) {
    setState(() {
      _markers = markers.map(
        (item) => item.infoWindow.title != '1'
          ? item
          : () {
            for (var i = 0; i < widget.locations.length; i++) {
              if (
                widget.locations[i].geoPosition == item.location.geoPosition
              ) {
                return item.copyWith(
                  infoWindowParam: InfoWindow(
                    title: 'new title'
                    snippet: 'new snippet',
                  )
                );
              }
            }
            return item;
          }()
      ).toSet();

    });
  }

@xni06
Copy link

xni06 commented Nov 14, 2019

ugly workaround:

  updateMarkers(Set<Marker> markers) {
    setState(() {
      _markers = markers.map(
        (item) => item.infoWindow.title != '1'
          ? item
          : () {
            for (var i = 0; i < widget.locations.length; i++) {
              if (
                widget.locations[i].geoPosition == item.location.geoPosition
              ) {
                return item.copyWith(
                  infoWindowParam: InfoWindow(
                    title: 'new title'
                    snippet: 'new snippet',
                  )
                );
              }
            }
            return item;
          }()
      ).toSet();

    });
  }

Good work, @felpsio - I've tweaked your solution for my own use case where I have approximately 3000 markers and works fine...

  _updateMarkers(Set<Marker> markers) {
    //TODO see https://github.com/giandifra/clustering_google_maps/issues/15
    setState(() {
      _markers = markers
          .map((clusterMarker) => () {
                for (var i = 0; i < widget.markers.length; i++) {
                  var marker = widget.markers[i];
                  if (marker.position == clusterMarker.position) {
                    return clusterMarker.copyWith(
                      infoWindowParam: marker.infoWindow,
                      iconParam: marker.icon,
                    );
                  }
                }
                return clusterMarker;
              }())
          .toSet();
    });
  }

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

No branches or pull requests

3 participants