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

[RN][iOS][google] Set region only when view has width&height #785

Merged
merged 1 commit into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions components/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,6 @@ class MapView extends React.Component {
return { provider: this.props.provider };
}

componentDidMount() {
const { region, initialRegion } = this.props;
if (region && this.state.isReady) {
this.map.setNativeProps({ region });
} else if (initialRegion && this.state.isReady) {
this.map.setNativeProps({ region: initialRegion });
}
}

componentWillUpdate(nextProps) {
const a = this.__lastRegion;
const b = nextProps.region;
Expand Down Expand Up @@ -407,6 +398,8 @@ class MapView extends React.Component {
_onLayout(e) {
const { region, initialRegion, onLayout } = this.props;
const { isReady } = this.state;
const { layout } = e.nativeEvent;
if (!layout.width || !layout.height) return;
if (region && isReady && !this.__layoutCalled) {
this.__layoutCalled = true;
this.map.setNativeProps({ region });
Expand Down
13 changes: 10 additions & 3 deletions docs/examples-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

## iOS

1. Install dependencies and open the workspace:
1. If you don't have bundler gem installed:

```
gem install bundler
```

2. Install dependencies and open the workspace:

```
cd example
npm install
cd ios
pod install
bundle install
bundle exec pod install

Choose a reason for hiding this comment

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

Do we really need both? Can it just be the second?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@spikebrehm unless there is a way to add a command to run pod install from the Gemfile I think we need both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh are you saying that bundle exec runs bundle install automatically? I don't know much about bundler tbh

Choose a reason for hiding this comment

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

oh no nevermind brainfart

open AirMapsExplorer.xcworkspace
```

2. Make sure the `AirMapsExplorer` target is selected and click `Run`
3. Make sure the `AirMapsExplorer` target is selected and click `Run`

## android

Expand Down
56 changes: 28 additions & 28 deletions example/ios/AirMapsExplorer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
21E6570C1D77591A00B75EE5 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21E6570B1D77591A00B75EE5 /* MobileCoreServices.framework */; };
21E6570E1D77591F00B75EE5 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21E6570D1D77591F00B75EE5 /* MapKit.framework */; };
21E657101D77594C00B75EE5 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21E6570F1D77594C00B75EE5 /* AudioToolbox.framework */; };
3E4E0B5921E01BC4043FD8CD /* Pods_AirMapsExplorer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3591658C00398534590C8751 /* Pods_AirMapsExplorer.framework */; };
8620CC871DBD814A00B79BFE /* AIRGMSMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8620CC6E1DBD814A00B79BFE /* AIRGMSMarker.m */; };
8620CC881DBD814A00B79BFE /* AIRGoogleMap.m in Sources */ = {isa = PBXBuildFile; fileRef = 8620CC701DBD814A00B79BFE /* AIRGoogleMap.m */; };
8620CC891DBD814A00B79BFE /* AIRGoogleMapCallout.m in Sources */ = {isa = PBXBuildFile; fileRef = 8620CC721DBD814A00B79BFE /* AIRGoogleMapCallout.m */; };
Expand All @@ -47,7 +48,6 @@
8620CC931DBD814A00B79BFE /* RCTConvert+GMSMapViewType.m in Sources */ = {isa = PBXBuildFile; fileRef = 8620CC861DBD814A00B79BFE /* RCTConvert+GMSMapViewType.m */; };
8697D6221DBEDE6100DB7D0F /* AIRGoogleMapCircle.m in Sources */ = {isa = PBXBuildFile; fileRef = 8697D6211DBEDE6100DB7D0F /* AIRGoogleMapCircle.m */; };
8697D6251DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8697D6241DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m */; };
C9315A21AD5A149EB5B40F29 /* Pods_AirMapsExplorer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24EB66BA0860A4DCD4CA3D77 /* Pods_AirMapsExplorer.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -113,8 +113,7 @@
21E6570B1D77591A00B75EE5 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
21E6570D1D77591F00B75EE5 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; };
21E6570F1D77594C00B75EE5 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
24EB66BA0860A4DCD4CA3D77 /* Pods_AirMapsExplorer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AirMapsExplorer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
309B9CD42BBCF38F87696E10 /* Pods-AirMapsExplorer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AirMapsExplorer.release.xcconfig"; path = "Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer.release.xcconfig"; sourceTree = "<group>"; };
3591658C00398534590C8751 /* Pods_AirMapsExplorer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AirMapsExplorer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8620CC6D1DBD814A00B79BFE /* AIRGMSMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIRGMSMarker.h; sourceTree = "<group>"; };
8620CC6E1DBD814A00B79BFE /* AIRGMSMarker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIRGMSMarker.m; sourceTree = "<group>"; };
8620CC6F1DBD814A00B79BFE /* AIRGoogleMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIRGoogleMap.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,7 +144,8 @@
8697D6211DBEDE6100DB7D0F /* AIRGoogleMapCircle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIRGoogleMapCircle.m; sourceTree = "<group>"; };
8697D6231DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIRGoogleMapCircleManager.h; sourceTree = "<group>"; };
8697D6241DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIRGoogleMapCircleManager.m; sourceTree = "<group>"; };
86C3F1E16CFF1D84E5317F85 /* Pods-AirMapsExplorer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AirMapsExplorer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer.debug.xcconfig"; sourceTree = "<group>"; };
BE5DE1E9AE25978F88CD940A /* Pods-AirMapsExplorer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AirMapsExplorer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer.debug.xcconfig"; sourceTree = "<group>"; };
E138AD0CDB08FE57B09B18F8 /* Pods-AirMapsExplorer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AirMapsExplorer.release.xcconfig"; path = "Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -164,7 +164,7 @@
21E6570E1D77591F00B75EE5 /* MapKit.framework in Frameworks */,
21E6570C1D77591A00B75EE5 /* MobileCoreServices.framework in Frameworks */,
21E6570A1D77591400B75EE5 /* SystemConfiguration.framework in Frameworks */,
C9315A21AD5A149EB5B40F29 /* Pods_AirMapsExplorer.framework in Frameworks */,
3E4E0B5921E01BC4043FD8CD /* Pods_AirMapsExplorer.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -183,20 +183,11 @@
21E6570D1D77591F00B75EE5 /* MapKit.framework */,
21E6570B1D77591A00B75EE5 /* MobileCoreServices.framework */,
21E657091D77591400B75EE5 /* SystemConfiguration.framework */,
24EB66BA0860A4DCD4CA3D77 /* Pods_AirMapsExplorer.framework */,
3591658C00398534590C8751 /* Pods_AirMapsExplorer.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
075E864247A56626509A7315 /* Pods */ = {
isa = PBXGroup;
children = (
86C3F1E16CFF1D84E5317F85 /* Pods-AirMapsExplorer.debug.xcconfig */,
309B9CD42BBCF38F87696E10 /* Pods-AirMapsExplorer.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
13B07FAE1A68108700A75B9A /* AirMapsExplorer */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -276,8 +267,8 @@
13B07FAE1A68108700A75B9A /* AirMapsExplorer */,
83CBBA001A601CBA00E9B192 /* Products */,
051AB288C799B62BE091B88A /* Frameworks */,
075E864247A56626509A7315 /* Pods */,
2BAA8C4A80B44CFBB3F83458 /* Libraries */,
C2ED0F349F22CC794F9BC33F /* Pods */,
);
indentWidth = 2;
sourceTree = "<group>";
Expand Down Expand Up @@ -330,6 +321,15 @@
path = ../../ios/AirGoogleMaps;
sourceTree = "<group>";
};
C2ED0F349F22CC794F9BC33F /* Pods */ = {
isa = PBXGroup;
children = (
BE5DE1E9AE25978F88CD940A /* Pods-AirMapsExplorer.debug.xcconfig */,
E138AD0CDB08FE57B09B18F8 /* Pods-AirMapsExplorer.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -355,13 +355,13 @@
isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "AirMapsExplorer" */;
buildPhases = (
B27D5F0DA3595C3A8B5D31D9 /* [CP] Check Pods Manifest.lock */,
CD9BCC809B77B74C231EE502 /* [CP] Check Pods Manifest.lock */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
A4662ADFE799D81334C129C7 /* [CP] Embed Pods Frameworks */,
DD0B426CF8A839A0248EA8C7 /* [CP] Copy Pods Resources */,
17E7BB4CEC38ABB7449E144E /* [CP] Embed Pods Frameworks */,
A6FAA2DEE540E08939F1B2AB /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -440,7 +440,7 @@
shellPath = /bin/sh;
shellScript = "../node_modules/react-native/packager/react-native-xcode.sh";
};
A4662ADFE799D81334C129C7 /* [CP] Embed Pods Frameworks */ = {
17E7BB4CEC38ABB7449E144E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand All @@ -455,34 +455,34 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
B27D5F0DA3595C3A8B5D31D9 /* [CP] Check Pods Manifest.lock */ = {
A6FAA2DEE540E08939F1B2AB /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Check Pods Manifest.lock";
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer-resources.sh\"\n";
showEnvVarsInLog = 0;
};
DD0B426CF8A839A0248EA8C7 /* [CP] Copy Pods Resources */ = {
CD9BCC809B77B74C231EE502 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer-resources.sh\"\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -602,7 +602,7 @@
};
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 86C3F1E16CFF1D84E5317F85 /* Pods-AirMapsExplorer.debug.xcconfig */;
baseConfigurationReference = BE5DE1E9AE25978F88CD940A /* Pods-AirMapsExplorer.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEAD_CODE_STRIPPING = NO;
Expand All @@ -625,7 +625,7 @@
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 309B9CD42BBCF38F87696E10 /* Pods-AirMapsExplorer.release.xcconfig */;
baseConfigurationReference = E138AD0CDB08FE57B09B18F8 /* Pods-AirMapsExplorer.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gem 'cocoapods', '~>1.1.1'
73 changes: 73 additions & 0 deletions example/ios/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.3)
activesupport (4.2.7.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
claide (1.0.1)
cocoapods (1.1.1)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.1, < 2.0)
cocoapods-core (= 1.1.1)
cocoapods-deintegrate (>= 1.0.1, < 2.0)
cocoapods-downloader (>= 1.1.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.1.1, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored (~> 1.2)
escape (~> 0.0.4)
fourflusher (~> 2.0.1)
gh_inspector (~> 1.0)
molinillo (~> 0.5.1)
nap (~> 1.0)
xcodeproj (>= 1.3.3, < 2.0)
cocoapods-core (1.1.1)
activesupport (>= 4.0.2, < 5)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.2)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.1.1)
nap (>= 0.8, < 2.0)
netrc (= 0.7.8)
cocoapods-try (1.1.0)
colored (1.2)
escape (0.0.4)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.0.2)
i18n (0.7.0)
json (1.8.3)
minitest (5.9.1)
molinillo (0.5.3)
nanaimo (0.2.2)
nap (1.1.0)
netrc (0.7.8)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
xcodeproj (1.4.1)
CFPropertyList (~> 2.3.3)
activesupport (>= 3)
claide (>= 1.0.1, < 2.0)
colored (~> 1.2)
nanaimo (~> 0.2.0)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.1.1)

BUNDLED WITH
1.10.6
4 changes: 2 additions & 2 deletions ios/AirMaps/AIRMapManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ - (void)handleMapTap:(UITapGestureRecognizer *)recognizer {
AIRMapPolyline *polyline = (AIRMapPolyline*) overlay;
if (polyline.onPress) {
float distance = [self distanceOfPoint:MKMapPointForCoordinate(tapCoordinate)
toPoly:overlay];
toPoly:polyline];
if (distance < nearestDistance) {
nearestDistance = distance;
nearestPolyline = overlay;
nearestPolyline = polyline;
}
}
}
Expand Down