Coder Social home page Coder Social logo

Comments (6)

xjebediahx avatar xjebediahx commented on June 6, 2024

Hello, I can confirm that. Plus the Callout is below the markers on iOS.

from react-native-map-clustering.

liqueflies avatar liqueflies commented on June 6, 2024

Anyone solved this?

from react-native-map-clustering.

vhoen avatar vhoen commented on June 6, 2024

Nope, still hoping someone will come up with a fix :)

from react-native-map-clustering.

vhoen avatar vhoen commented on June 6, 2024

I came up with some sort of hack that I am not so proud of but it seems to do the job. If anyone has a better solution, I would be glad to use it :

constructor(props) {
  super(props);
  this.showCallout = this.showCallout.bind(this);

  this.state = {
    selectedMarker: null,
    selectedMarkersList: [],
  };
}

getMarkers() {
  return this.state.parks.map((park, i) => (
    <Marker
      key={park.code}
      coordinate={{
        latitude: parseFloat(park.lat),
        longitude: parseFloat(park.lng),
      }}
      ref={(c) => {
        this[`marker_${i}`] = c;
      }}
      onPress={() => {
        if (Platform.OS === 'android') {
          const markerId = `marker_${i}`;
          if (!isUndefined(this[markerId])) {
            this.setState({
              selectedMarker: markerId,
              // Needed to keep a list of already used callout, so that they
              // are removed by react-native-maps
              // prevents this kind of error : https://stackoverflow.com/questions/41819759/trying-to-remove-a-view-index-above-child-count-error
              selectedMarkersList: [...this.state.selectedMarkersList, markerId],
            }, () => setTimeout(() => this.showCallout(i), 250));
          }
        } else {
          this[`marker_${i}`].showCallout();
        }
      }}
      style={{ zIndex: 10 }}
    >
      {(() => {
        if (Platform.OS === 'android') {
          const markerId = `marker_${i}`;
          if (
            this.state.selectedMarker === markerId
            || this.state.selectedMarkersList.indexOf(markerId) !== -1
          ) {
            return this.renderCallout(park, i);
          }

          return null;
        }

        return this.renderCallout(park, i);
      })()}
    </Marker>
  ));
}

showCallout(i) {
  if (!isUndefined(this[`marker_${i}`]) && this[`marker_${i}`].showCallout) {
    this[`marker_${i}`].showCallout();
  }
}

renderMap() {
  return (
    <MapView
      region={MAP_REGION}
      ref={(c) => { this.mapView = c; }}
      style={{ flex: 1, zIndex: 10 }}
      clusterTextColor={PVCPTheme.colors.PV_BLUE_DARK}
      clusterTextSize={15}
      clusterBorderColor="transparent"
      clusterBorderWidth={0}
      customClusterMarkerDesign={this.getCustomClusterMarkerDesign()}
      onClusterPress={(coordinates) => this.onClusterPress(coordinates)}
      rotateEnabled={false}
    >
      {this.getMarkers()}
    </MapView>
  );
}

Long story short : Callout is never rendered unless marker has been clicked.

from react-native-map-clustering.

venits avatar venits commented on June 6, 2024

I released new version of this library. If this issue will be still relevant please let me know 👍

from react-native-map-clustering.

gustavodev90 avatar gustavodev90 commented on June 6, 2024

This issue is still relevant today.
After tapping on the map marker, callout pops up and immediately disappears. It requires second time tap to work properly.

"react-native-map-clustering": "^3.4.2"
"react-native": "0.64.2"

from react-native-map-clustering.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.