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

MapView to support MKPointAnnotation using new attribute annotate in Map... #810

Closed
wants to merge 4 commits into from

Conversation

ginamdar
Copy link
Contributor

MapView to support Pin annotation

var pinLocation1 = {
        latitude: property.latitude,
        longitude: property.longitude,
        title: "I'm here.."
    };
    var pinLocation2 = {
        latitude: property.latitude + 0.1,
        longitude: property.longitude,
        title: "I'm here too!"
    };
this.state = {propertyPoints: [pinLocation1, pinLocation2]};
<MapView style={styles.map} region={this.state.region} annotations={this.state.propertyPoints}>
</MapView>

mapview-pinannotations

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 11, 2015
@ginamdar
Copy link
Contributor Author

Please review the changes for supporting annotation inside MapView

@ginamdar ginamdar closed this Apr 11, 2015
@ginamdar ginamdar reopened this Apr 11, 2015
if (title.length){
pin.title = title;
}
[view addAnnotation:pin];
Copy link
Contributor

Choose a reason for hiding this comment

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

This is never going to remove the pin, right?

@ginamdar
Copy link
Contributor Author

Yes correct

@nicklockwood
Copy link
Contributor

Wouldn't it make more sense to provide an array of pins?

Also, we'd really want to be able to remove them. We could do that by maintaining a dictionary of annotations keyed by coordinate internally and when the array is updated we'd remove the ones that are no longer in the array.

@vjeux vjeux closed this in 7a68691 Apr 15, 2015
@dvdhsu
Copy link

dvdhsu commented Apr 16, 2015

Running UIExplorer, going into MapView, and tapping on the annotation freezes the app. I've tried this with a blank project with MapView, along with an ordinary annotation; same problem.

Occurs in both simulator and device. Inspecting memory usage via Xcode reveals that after annotation is tapped, memory usage keeps on rising, and CPU suddenly jumps to ~180%, and stays around there.

screenshot 2015-04-15 20 39 03

@nicklockwood
Copy link
Contributor

That's weird … I'm seeing this on iOS 8.1 simulator, but not on iOS 8.3

@nicklockwood
Copy link
Contributor

OK, I've found the problem. I'm landing a fix ASAP, but in the meantime if it's blocking you, you can fix it by replacing the layoutSubviews method in RCTMap.m with

- (void)reactSetFrame:(CGRect)frame
{
  self.frame = frame;
}

- (void)layoutSubviews
{
  [super layoutSubviews];

  if (_legalLabel) {
    dispatch_async(dispatch_get_main_queue(), ^{
      CGRect frame = _legalLabel.frame;
      if (_legalLabelInsets.left) {
        frame.origin.x = _legalLabelInsets.left;
      } else if (_legalLabelInsets.right) {
        frame.origin.x = self.frame.size.width - _legalLabelInsets.right - frame.size.width;
      }
      if (_legalLabelInsets.top) {
        frame.origin.y = _legalLabelInsets.top;
      } else if (_legalLabelInsets.bottom) {
        frame.origin.y = self.frame.size.height - _legalLabelInsets.bottom - frame.size.height;
      }
      _legalLabel.frame = frame;
    });
  }
}

@matth3wga0
Copy link

Why shouldn't the annotation be a node?

At least provide a way to customize the annotation, replace the default drop pin on iOS, leverage the appearance between iOS and Android.

ayushjainrksh referenced this pull request in MLH-Fellowship/react-native Jul 2, 2020
acoates-ms added a commit to acoates-ms/react-native that referenced this pull request Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants