├── .eslintignore
├── .eslintrc
├── .flowconfig
├── .gitignore
├── .npmignore
├── .travis.yml
├── .watchmanconfig
├── CHANGELOG.md
├── LICENSE
├── README.md
├── android
├── build.gradle
├── gradle-maven-push.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── airbnb
│ └── android
│ └── react
│ └── maps
│ ├── AirMapCallout.java
│ ├── AirMapCalloutManager.java
│ ├── AirMapCircle.java
│ ├── AirMapCircleManager.java
│ ├── AirMapFeature.java
│ ├── AirMapLiteManager.java
│ ├── AirMapManager.java
│ ├── AirMapMarker.java
│ ├── AirMapMarkerManager.java
│ ├── AirMapModule.java
│ ├── AirMapPolygon.java
│ ├── AirMapPolygonManager.java
│ ├── AirMapPolyline.java
│ ├── AirMapPolylineManager.java
│ ├── AirMapUrlTile.java
│ ├── AirMapUrlTileManager.java
│ ├── AirMapView.java
│ ├── LatLngBoundsUtils.java
│ ├── MapsPackage.java
│ ├── MapsUtilsModule.java
│ ├── PolyUtils.java
│ ├── RegionChangeEvent.java
│ └── SizeReportingShadowNode.java
├── components
├── AnimatedRegion.js
├── MapCallout.js
├── MapCircle.js
├── MapMarker.js
├── MapPolygon.js
├── MapPolyline.js
├── MapUrlTile.js
├── MapUtils.js
├── MapView.js
├── ProviderConstants.js
└── decorateMapComponent.js
├── docs
├── callout.md
├── circle.md
├── examples-setup.md
├── installation.md
├── mapview.md
├── marker.md
├── polygon.md
└── polyline.md
├── example
├── .eslintrc
├── .flowconfig
├── .gitignore
├── .watchmanconfig
├── App.js
├── android
│ ├── app
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ ├── react.gradle
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── airbnb
│ │ │ │ └── android
│ │ │ │ └── react
│ │ │ │ └── maps
│ │ │ │ └── example
│ │ │ │ ├── ExampleApplication.java
│ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── examples
│ ├── AnimatedMarkers.js
│ ├── AnimatedPriceMarker.js
│ ├── AnimatedViews.js
│ ├── CachedMap.js
│ ├── Callouts.js
│ ├── CustomCallout.js
│ ├── CustomMarkers.js
│ ├── CustomOverlay.js
│ ├── CustomOverlayXMarksTheSpot.js
│ ├── CustomTiles.js
│ ├── DefaultMarkers.js
│ ├── DisplayLatLng.js
│ ├── DraggableMarkers.js
│ ├── EventListener.js
│ ├── FitToCoordinates.js
│ ├── FitToSuppliedMarkers.js
│ ├── LegalLabel.js
│ ├── LiteMapView.js
│ ├── LoadingMap.js
│ ├── MapStyle.js
│ ├── MarkerTypes.js
│ ├── Overlays.js
│ ├── PanController.js
│ ├── PolygonCreator.js
│ ├── PolylineCreator.js
│ ├── PriceMarker.js
│ ├── SetNativePropsOverlays.js
│ ├── StaticMap.js
│ ├── TakeSnapshot.js
│ ├── ViewsAsMarkers.js
│ ├── ZIndexMarkers.js
│ └── assets
│ │ ├── flag-blue.png
│ │ └── flag-pink.png
├── index.android.js
├── index.ios.js
├── ios
│ ├── AirMapsExplorer.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── AirMapsExplorer.xcscheme
│ ├── AirMapsExplorer
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Base.lproj
│ │ │ └── LaunchScreen.xib
│ │ ├── Images.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ └── main.m
│ ├── AirMapsExplorerTests
│ │ ├── AirMapsExplorerTests.m
│ │ └── Info.plist
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Podfile
│ └── Podfile.lock
├── package.json
├── scripts
│ ├── .eslintrc
│ └── watch-and-copy-src.js
└── test.sh
├── index.js
├── ios
├── AirGoogleMaps
│ ├── AIRGMSMarker.h
│ ├── AIRGMSMarker.m
│ ├── AIRGoogleMap.h
│ ├── AIRGoogleMap.m
│ ├── AIRGoogleMapCallout.h
│ ├── AIRGoogleMapCallout.m
│ ├── AIRGoogleMapCalloutManager.h
│ ├── AIRGoogleMapCalloutManager.m
│ ├── AIRGoogleMapCircle.h
│ ├── AIRGoogleMapCircle.m
│ ├── AIRGoogleMapCircleManager.h
│ ├── AIRGoogleMapCircleManager.m
│ ├── AIRGoogleMapManager.h
│ ├── AIRGoogleMapManager.m
│ ├── AIRGoogleMapMarker.h
│ ├── AIRGoogleMapMarker.m
│ ├── AIRGoogleMapMarkerManager.h
│ ├── AIRGoogleMapMarkerManager.m
│ ├── AIRGoogleMapPolygon.h
│ ├── AIRGoogleMapPolygon.m
│ ├── AIRGoogleMapPolygonManager.h
│ ├── AIRGoogleMapPolygonManager.m
│ ├── AIRGoogleMapPolyline.h
│ ├── AIRGoogleMapPolyline.m
│ ├── AIRGoogleMapPolylineManager.h
│ ├── AIRGoogleMapPolylineManager.m
│ ├── AIRGoogleMapURLTileManager.m
│ ├── AIRGoogleMapUrlTile.h
│ ├── AIRGoogleMapUrlTile.m
│ ├── AIRGoogleMapUrlTileManager.h
│ ├── DummyView.h
│ ├── DummyView.m
│ ├── RCTConvert+GMSMapViewType.h
│ └── RCTConvert+GMSMapViewType.m
├── AirMaps.xcodeproj
│ └── project.pbxproj
└── AirMaps
│ ├── AIRMap.h
│ ├── AIRMap.m
│ ├── AIRMapCallout.h
│ ├── AIRMapCallout.m
│ ├── AIRMapCalloutManager.h
│ ├── AIRMapCalloutManager.m
│ ├── AIRMapCircle.h
│ ├── AIRMapCircle.m
│ ├── AIRMapCircleManager.h
│ ├── AIRMapCircleManager.m
│ ├── AIRMapCoordinate.h
│ ├── AIRMapCoordinate.m
│ ├── AIRMapManager.h
│ ├── AIRMapManager.m
│ ├── AIRMapMarker.h
│ ├── AIRMapMarker.m
│ ├── AIRMapMarkerManager.h
│ ├── AIRMapMarkerManager.m
│ ├── AIRMapPolygon.h
│ ├── AIRMapPolygon.m
│ ├── AIRMapPolygonManager.h
│ ├── AIRMapPolygonManager.m
│ ├── AIRMapPolyline.h
│ ├── AIRMapPolyline.m
│ ├── AIRMapPolylineManager.h
│ ├── AIRMapPolylineManager.m
│ ├── AIRMapSnapshot.h
│ ├── AIRMapUrlTile.h
│ ├── AIRMapUrlTile.m
│ ├── AIRMapUrlTileManager.h
│ ├── AIRMapUrlTileManager.m
│ ├── Callout
│ ├── SMCalloutView.h
│ └── SMCalloutView.m
│ ├── RCTConvert+MoreMapKit.h
│ └── RCTConvert+MoreMapKit.m
├── package.json
├── react-native-google-maps.podspec
├── react-native-maps.podspec
└── scripts
└── update-version.js
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": "airbnb",
4 | "plugins": [
5 | "prefer-object-spread"
6 | ],
7 | "rules": {
8 | "prefer-object-spread/prefer-object-spread": 2,
9 | "react/jsx-filename-extension": 0,
10 | "react/prefer-stateless-function": 0,
11 | "react/sort-comp": 0,
12 | "no-use-before-define": 0,
13 | "no-underscore-dangle": 0,
14 | "import/no-unresolved": [2, { "ignore": ["react"] }]
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 |
3 | # We fork some components by platform.
4 | .*/*.web.js
5 | .*/*.android.js
6 |
7 | # Some modules have their own node_modules with overlap
8 | .*/node_modules/node-haste/.*
9 |
10 | # Ugh
11 | .*/node_modules/babel.*
12 | .*/node_modules/babylon.*
13 | .*/node_modules/invariant.*
14 |
15 | # Ignore react and fbjs where there are overlaps, but don't ignore
16 | # anything that react-native relies on
17 | .*/node_modules/fbjs-haste/.*/__tests__/.*
18 | .*/node_modules/fbjs-haste/__forks__/Map.js
19 | .*/node_modules/fbjs-haste/__forks__/Promise.js
20 | .*/node_modules/fbjs-haste/__forks__/fetch.js
21 | .*/node_modules/fbjs-haste/core/ExecutionEnvironment.js
22 | .*/node_modules/fbjs-haste/core/isEmpty.js
23 | .*/node_modules/fbjs-haste/crypto/crc32.js
24 | .*/node_modules/fbjs-haste/stubs/ErrorUtils.js
25 | .*/node_modules/react-haste/React.js
26 | .*/node_modules/react-haste/renderers/dom/ReactDOM.js
27 | .*/node_modules/react-haste/renderers/shared/event/eventPlugins/ResponderEventPlugin.js
28 |
29 | # Ignore commoner tests
30 | .*/node_modules/commoner/test/.*
31 |
32 | # See https://github.com/facebook/flow/issues/442
33 | .*/react-tools/node_modules/commoner/lib/reader.js
34 |
35 | # Ignore jest
36 | .*/node_modules/jest-cli/.*
37 |
38 | # Ignore Website
39 | .*/website/.*
40 |
41 | [include]
42 |
43 | [libs]
44 | node_modules/react-native/Libraries/react-native/react-native-interface.js
45 |
46 | [options]
47 | module.system=haste
48 |
49 | munge_underscores=true
50 |
51 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
52 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
53 |
54 | suppress_type=$FlowIssue
55 | suppress_type=$FlowFixMe
56 | suppress_type=$FixMe
57 |
58 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-8]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
59 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-8]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+
60 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
61 |
62 | [version]
63 | 0.18.1
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | project.xcworkspace
24 |
25 | # Android/IJ
26 | #
27 | .idea
28 | *.iml
29 | .gradle
30 | local.properties
31 |
32 | # node.js
33 | #
34 | node_modules/
35 | npm-debug.log
36 | Pods/
37 | AirMapsExplorer.xcworkspace/
38 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | example
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - "6"
5 |
6 | cache:
7 | directories:
8 | - node_modules
9 | - example/node_modules
10 |
11 | script: npm run lint
12 |
--------------------------------------------------------------------------------
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Airbnb
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | apply plugin: 'com.android.library'
4 | apply from: 'gradle-maven-push.gradle'
5 |
6 | buildscript {
7 | repositories {
8 | mavenLocal()
9 | jcenter()
10 | maven {
11 | // For developing the library outside the context of the example app, expect `react-native`
12 | // to be installed at `./node_modules`.
13 | url "$projectDir/../node_modules/react-native/android"
14 | }
15 | maven {
16 | // For developing the example app.
17 | url "$projectDir/../../react-native/android"
18 | }
19 | }
20 | dependencies {
21 | classpath 'com.android.tools.build:gradle:2.1.0'
22 | }
23 | }
24 |
25 | allprojects {
26 | repositories {
27 | mavenLocal()
28 | jcenter()
29 | maven {
30 | // For developing the library outside the context of the example app, expect `react-native`
31 | // to be installed at `./node_modules`.
32 | url "$projectDir/../node_modules/react-native/android"
33 | }
34 | maven {
35 | // For developing the example app.
36 | url "$projectDir/../../react-native/android"
37 | }
38 | }
39 | }
40 |
41 | android {
42 | compileSdkVersion 23
43 | buildToolsVersion "23.0.3"
44 |
45 | defaultConfig {
46 | minSdkVersion 16
47 | targetSdkVersion 22
48 | }
49 |
50 | lintOptions {
51 | disable 'InvalidPackage'
52 | }
53 | }
54 |
55 | dependencies {
56 | compile "com.facebook.react:react-native:+"
57 | compile "com.google.android.gms:play-services-base:9.8.0"
58 | compile "com.google.android.gms:play-services-maps:9.8.0"
59 | compile "com.google.maps.android:android-maps-utils:0.5"
60 | }
61 |
--------------------------------------------------------------------------------
/android/gradle-maven-push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'maven'
18 | apply plugin: 'signing'
19 |
20 | def isReleaseBuild() {
21 | return VERSION_NAME.contains("SNAPSHOT") == false
22 | }
23 |
24 | def getReleaseRepositoryUrl() {
25 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27 | }
28 |
29 | def getSnapshotRepositoryUrl() {
30 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31 | : "https://oss.sonatype.org/content/repositories/snapshots/"
32 | }
33 |
34 | def getRepositoryUsername() {
35 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
36 | }
37 |
38 | def getRepositoryPassword() {
39 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
40 | }
41 |
42 | afterEvaluate { project ->
43 | uploadArchives {
44 | repositories {
45 | mavenDeployer {
46 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
47 |
48 | pom.groupId = GROUP
49 | pom.artifactId = POM_ARTIFACT_ID
50 | pom.version = VERSION_NAME
51 |
52 | repository(url: getReleaseRepositoryUrl()) {
53 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
54 | }
55 | snapshotRepository(url: getSnapshotRepositoryUrl()) {
56 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57 | }
58 |
59 | pom.project {
60 | name POM_NAME
61 | packaging POM_PACKAGING
62 | description POM_DESCRIPTION
63 | url POM_URL
64 |
65 | scm {
66 | url POM_SCM_URL
67 | connection POM_SCM_CONNECTION
68 | developerConnection POM_SCM_DEV_CONNECTION
69 | }
70 |
71 | licenses {
72 | license {
73 | name POM_LICENSE_NAME
74 | url POM_LICENSE_URL
75 | distribution POM_LICENSE_DIST
76 | }
77 | }
78 |
79 | developers {
80 | developer {
81 | id POM_DEVELOPER_ID
82 | name POM_DEVELOPER_NAME
83 | }
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
90 | signing {
91 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
92 | sign configurations.archives
93 | }
94 |
95 | task androidJavadocs(type: Javadoc) {
96 | source = android.sourceSets.main.java.srcDirs
97 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
98 | }
99 |
100 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
101 | classifier = 'javadoc'
102 | from androidJavadocs.destinationDir
103 | }
104 |
105 | task androidSourcesJar(type: Jar) {
106 | classifier = 'sources'
107 | from android.sourceSets.main.java.sourceFiles
108 | }
109 |
110 | artifacts {
111 | archives androidSourcesJar
112 | archives androidJavadocsJar
113 | }
114 | }
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_CODE=2
2 | VERSION_NAME=0.13.0
3 | GROUP=com.airbnb.android
4 |
5 | POM_DESCRIPTION=React Native Map view component for Android
6 | POM_URL=https://github.com/airbnb/react-native-maps/tree/new-scv
7 | POM_SCM_URL=https://github.com/airbnb/react-native-maps/tree/new-scv
8 | POM_SCM_CONNECTION=scm:git@github.com:airbnb/react-native-maps.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:airbnb/react-native-maps.git
10 | POM_LICENSE_NAME=MIT
11 | POM_LICENSE_URL=https://github.com/airbnb/react-native-maps/blob/master/LICENSE
12 | POM_LICENSE_DIST=repo
13 | POM_DEVELOPER_ID=airbnb
14 | POM_DEVELOPER_NAME=Leland Richardson
15 |
16 | POM_NAME=ReactNative Maps library
17 | POM_ARTIFACT_ID=react-native-maps
18 | POM_PACKAGING=aar
19 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Sep 10 19:01:47 BRT 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapCallout.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.views.view.ReactViewGroup;
6 |
7 | public class AirMapCallout extends ReactViewGroup {
8 | private boolean tooltip = false;
9 | public int width;
10 | public int height;
11 |
12 | public AirMapCallout(Context context) {
13 | super(context);
14 | }
15 |
16 | public void setTooltip(boolean tooltip) {
17 | this.tooltip = tooltip;
18 | }
19 |
20 | public boolean getTooltip() {
21 | return this.tooltip;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapCalloutManager.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import com.facebook.react.common.MapBuilder;
4 | import com.facebook.react.uimanager.LayoutShadowNode;
5 | import com.facebook.react.uimanager.ThemedReactContext;
6 | import com.facebook.react.uimanager.ViewGroupManager;
7 | import com.facebook.react.uimanager.annotations.ReactProp;
8 |
9 | import java.util.Map;
10 |
11 | import javax.annotation.Nullable;
12 |
13 | public class AirMapCalloutManager extends ViewGroupManager {
14 |
15 | @Override
16 | public String getName() {
17 | return "AIRMapCallout";
18 | }
19 |
20 | @Override
21 | public AirMapCallout createViewInstance(ThemedReactContext context) {
22 | return new AirMapCallout(context);
23 | }
24 |
25 | @ReactProp(name = "tooltip", defaultBoolean = false)
26 | public void setTooltip(AirMapCallout view, boolean tooltip) {
27 | view.setTooltip(tooltip);
28 | }
29 |
30 | @Override
31 | @Nullable
32 | public Map getExportedCustomDirectEventTypeConstants() {
33 | return MapBuilder.of("onPress", MapBuilder.of("registrationName", "onPress"));
34 | }
35 |
36 | @Override
37 | public LayoutShadowNode createShadowNodeInstance() {
38 | // we use a custom shadow node that emits the width/height of the view
39 | // after layout with the updateExtraData method. Without this, we can't generate
40 | // a bitmap of the appropriate width/height of the rendered view.
41 | return new SizeReportingShadowNode();
42 | }
43 |
44 | @Override
45 | public void updateExtraData(AirMapCallout view, Object extraData) {
46 | // This method is called from the shadow node with the width/height of the rendered
47 | // marker view.
48 | //noinspection unchecked
49 | Map data = (Map) extraData;
50 | float width = data.get("width");
51 | float height = data.get("height");
52 | view.width = (int) width;
53 | view.height = (int) height;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapCircle.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.android.gms.maps.GoogleMap;
6 | import com.google.android.gms.maps.model.Circle;
7 | import com.google.android.gms.maps.model.CircleOptions;
8 | import com.google.android.gms.maps.model.LatLng;
9 |
10 | public class AirMapCircle extends AirMapFeature {
11 |
12 | private CircleOptions circleOptions;
13 | private Circle circle;
14 |
15 | private LatLng center;
16 | private double radius;
17 | private int strokeColor;
18 | private int fillColor;
19 | private float strokeWidth;
20 | private float zIndex;
21 |
22 | public AirMapCircle(Context context) {
23 | super(context);
24 | }
25 |
26 | public void setCenter(LatLng center) {
27 | this.center = center;
28 | if (circle != null) {
29 | circle.setCenter(this.center);
30 | }
31 | }
32 |
33 | public void setRadius(double radius) {
34 | this.radius = radius;
35 | if (circle != null) {
36 | circle.setRadius(this.radius);
37 | }
38 | }
39 |
40 | public void setFillColor(int color) {
41 | this.fillColor = color;
42 | if (circle != null) {
43 | circle.setFillColor(color);
44 | }
45 | }
46 |
47 | public void setStrokeColor(int color) {
48 | this.strokeColor = color;
49 | if (circle != null) {
50 | circle.setStrokeColor(color);
51 | }
52 | }
53 |
54 | public void setStrokeWidth(float width) {
55 | this.strokeWidth = width;
56 | if (circle != null) {
57 | circle.setStrokeWidth(width);
58 | }
59 | }
60 |
61 | public void setZIndex(float zIndex) {
62 | this.zIndex = zIndex;
63 | if (circle != null) {
64 | circle.setZIndex(zIndex);
65 | }
66 | }
67 |
68 | public CircleOptions getCircleOptions() {
69 | if (circleOptions == null) {
70 | circleOptions = createCircleOptions();
71 | }
72 | return circleOptions;
73 | }
74 |
75 | private CircleOptions createCircleOptions() {
76 | CircleOptions options = new CircleOptions();
77 | options.center(center);
78 | options.radius(radius);
79 | options.fillColor(fillColor);
80 | options.strokeColor(strokeColor);
81 | options.strokeWidth(strokeWidth);
82 | options.zIndex(zIndex);
83 | return options;
84 | }
85 |
86 | @Override
87 | public Object getFeature() {
88 | return circle;
89 | }
90 |
91 | @Override
92 | public void addToMap(GoogleMap map) {
93 | circle = map.addCircle(getCircleOptions());
94 | }
95 |
96 | @Override
97 | public void removeFromMap(GoogleMap map) {
98 | circle.remove();
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapCircleManager.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.util.DisplayMetrics;
7 | import android.view.WindowManager;
8 |
9 | import com.facebook.react.bridge.ReactApplicationContext;
10 | import com.facebook.react.bridge.ReadableMap;
11 | import com.facebook.react.uimanager.ThemedReactContext;
12 | import com.facebook.react.uimanager.ViewGroupManager;
13 | import com.facebook.react.uimanager.annotations.ReactProp;
14 | import com.google.android.gms.maps.model.LatLng;
15 |
16 | public class AirMapCircleManager extends ViewGroupManager {
17 | private final DisplayMetrics metrics;
18 |
19 | public AirMapCircleManager(ReactApplicationContext reactContext) {
20 | super();
21 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
22 | metrics = new DisplayMetrics();
23 | ((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
24 | .getDefaultDisplay()
25 | .getRealMetrics(metrics);
26 | } else {
27 | metrics = reactContext.getResources().getDisplayMetrics();
28 | }
29 | }
30 |
31 | @Override
32 | public String getName() {
33 | return "AIRMapCircle";
34 | }
35 |
36 | @Override
37 | public AirMapCircle createViewInstance(ThemedReactContext context) {
38 | return new AirMapCircle(context);
39 | }
40 |
41 | @ReactProp(name = "center")
42 | public void setCenter(AirMapCircle view, ReadableMap center) {
43 | view.setCenter(new LatLng(center.getDouble("latitude"), center.getDouble("longitude")));
44 | }
45 |
46 | @ReactProp(name = "radius", defaultDouble = 0)
47 | public void setRadius(AirMapCircle view, double radius) {
48 | view.setRadius(radius);
49 | }
50 |
51 | @ReactProp(name = "strokeWidth", defaultFloat = 1f)
52 | public void setStrokeWidth(AirMapCircle view, float widthInPoints) {
53 | float widthInScreenPx = metrics.density * widthInPoints; // done for parity with iOS
54 | view.setStrokeWidth(widthInScreenPx);
55 | }
56 |
57 | @ReactProp(name = "fillColor", defaultInt = Color.RED, customType = "Color")
58 | public void setFillColor(AirMapCircle view, int color) {
59 | view.setFillColor(color);
60 | }
61 |
62 | @ReactProp(name = "strokeColor", defaultInt = Color.RED, customType = "Color")
63 | public void setStrokeColor(AirMapCircle view, int color) {
64 | view.setStrokeColor(color);
65 | }
66 |
67 | @ReactProp(name = "zIndex", defaultFloat = 1.0f)
68 | public void setZIndex(AirMapCircle view, float zIndex) {
69 | view.setZIndex(zIndex);
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapFeature.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.views.view.ReactViewGroup;
6 | import com.google.android.gms.maps.GoogleMap;
7 |
8 | public abstract class AirMapFeature extends ReactViewGroup {
9 | public AirMapFeature(Context context) {
10 | super(context);
11 | }
12 |
13 | public abstract void addToMap(GoogleMap map);
14 |
15 | public abstract void removeFromMap(GoogleMap map);
16 |
17 | public abstract Object getFeature();
18 | }
19 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapLiteManager.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import com.facebook.react.bridge.ReactApplicationContext;
4 | import com.google.android.gms.maps.GoogleMapOptions;
5 |
6 | public class AirMapLiteManager extends AirMapManager {
7 |
8 | private static final String REACT_CLASS = "AIRMapLite";
9 |
10 | @Override
11 | public String getName() {
12 | return REACT_CLASS;
13 | }
14 |
15 | public AirMapLiteManager(ReactApplicationContext context) {
16 | super(context);
17 | this.googleMapOptions = new GoogleMapOptions().liteMode(true);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapPolygon.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.bridge.ReadableArray;
6 | import com.facebook.react.bridge.ReadableMap;
7 | import com.google.android.gms.maps.GoogleMap;
8 | import com.google.android.gms.maps.model.LatLng;
9 | import com.google.android.gms.maps.model.Polygon;
10 | import com.google.android.gms.maps.model.PolygonOptions;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | public class AirMapPolygon extends AirMapFeature {
16 |
17 | private PolygonOptions polygonOptions;
18 | private Polygon polygon;
19 |
20 | private List coordinates;
21 | private int strokeColor;
22 | private int fillColor;
23 | private float strokeWidth;
24 | private boolean geodesic;
25 | private float zIndex;
26 |
27 | public AirMapPolygon(Context context) {
28 | super(context);
29 | }
30 |
31 | public void setCoordinates(ReadableArray coordinates) {
32 | // it's kind of a bummer that we can't run map() or anything on the ReadableArray
33 | this.coordinates = new ArrayList<>(coordinates.size());
34 | for (int i = 0; i < coordinates.size(); i++) {
35 | ReadableMap coordinate = coordinates.getMap(i);
36 | this.coordinates.add(i,
37 | new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
38 | }
39 | if (polygon != null) {
40 | polygon.setPoints(this.coordinates);
41 | }
42 | }
43 |
44 | public void setFillColor(int color) {
45 | this.fillColor = color;
46 | if (polygon != null) {
47 | polygon.setFillColor(color);
48 | }
49 | }
50 |
51 | public void setStrokeColor(int color) {
52 | this.strokeColor = color;
53 | if (polygon != null) {
54 | polygon.setStrokeColor(color);
55 | }
56 | }
57 |
58 | public void setStrokeWidth(float width) {
59 | this.strokeWidth = width;
60 | if (polygon != null) {
61 | polygon.setStrokeWidth(width);
62 | }
63 | }
64 |
65 | public void setGeodesic(boolean geodesic) {
66 | this.geodesic = geodesic;
67 | if (polygon != null) {
68 | polygon.setGeodesic(geodesic);
69 | }
70 | }
71 |
72 | public void setZIndex(float zIndex) {
73 | this.zIndex = zIndex;
74 | if (polygon != null) {
75 | polygon.setZIndex(zIndex);
76 | }
77 | }
78 |
79 | public PolygonOptions getPolygonOptions() {
80 | if (polygonOptions == null) {
81 | polygonOptions = createPolygonOptions();
82 | }
83 | return polygonOptions;
84 | }
85 |
86 | private PolygonOptions createPolygonOptions() {
87 | PolygonOptions options = new PolygonOptions();
88 | options.addAll(coordinates);
89 | options.fillColor(fillColor);
90 | options.strokeColor(strokeColor);
91 | options.strokeWidth(strokeWidth);
92 | options.geodesic(geodesic);
93 | options.zIndex(zIndex);
94 | return options;
95 | }
96 |
97 | @Override
98 | public Object getFeature() {
99 | return polygon;
100 | }
101 |
102 | @Override
103 | public void addToMap(GoogleMap map) {
104 | polygon = map.addPolygon(getPolygonOptions());
105 | polygon.setClickable(true);
106 | }
107 |
108 | @Override
109 | public void removeFromMap(GoogleMap map) {
110 | polygon.remove();
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapPolygonManager.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.util.DisplayMetrics;
7 | import android.view.WindowManager;
8 |
9 | import com.facebook.react.bridge.ReactApplicationContext;
10 | import com.facebook.react.bridge.ReadableArray;
11 | import com.facebook.react.common.MapBuilder;
12 | import com.facebook.react.uimanager.ThemedReactContext;
13 | import com.facebook.react.uimanager.ViewGroupManager;
14 | import com.facebook.react.uimanager.annotations.ReactProp;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 | import javax.annotation.Nullable;
19 |
20 | public class AirMapPolygonManager extends ViewGroupManager {
21 | private final DisplayMetrics metrics;
22 |
23 | public AirMapPolygonManager(ReactApplicationContext reactContext) {
24 | super();
25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
26 | metrics = new DisplayMetrics();
27 | ((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
28 | .getDefaultDisplay()
29 | .getRealMetrics(metrics);
30 | } else {
31 | metrics = reactContext.getResources().getDisplayMetrics();
32 | }
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "AIRMapPolygon";
38 | }
39 |
40 | @Override
41 | public AirMapPolygon createViewInstance(ThemedReactContext context) {
42 | return new AirMapPolygon(context);
43 | }
44 |
45 | @ReactProp(name = "coordinates")
46 | public void setCoordinate(AirMapPolygon view, ReadableArray coordinates) {
47 | view.setCoordinates(coordinates);
48 | }
49 |
50 | @ReactProp(name = "strokeWidth", defaultFloat = 1f)
51 | public void setStrokeWidth(AirMapPolygon view, float widthInPoints) {
52 | float widthInScreenPx = metrics.density * widthInPoints; // done for parity with iOS
53 | view.setStrokeWidth(widthInScreenPx);
54 | }
55 |
56 | @ReactProp(name = "fillColor", defaultInt = Color.RED, customType = "Color")
57 | public void setFillColor(AirMapPolygon view, int color) {
58 | view.setFillColor(color);
59 | }
60 |
61 | @ReactProp(name = "strokeColor", defaultInt = Color.RED, customType = "Color")
62 | public void setStrokeColor(AirMapPolygon view, int color) {
63 | view.setStrokeColor(color);
64 | }
65 |
66 | @ReactProp(name = "geodesic", defaultBoolean = false)
67 | public void setGeodesic(AirMapPolygon view, boolean geodesic) {
68 | view.setGeodesic(geodesic);
69 | }
70 |
71 | @ReactProp(name = "zIndex", defaultFloat = 1.0f)
72 | public void setZIndex(AirMapPolygon view, float zIndex) {
73 | view.setZIndex(zIndex);
74 | }
75 |
76 | @Override
77 | @Nullable
78 | public Map getExportedCustomDirectEventTypeConstants() {
79 | return MapBuilder.of(
80 | "onPress", MapBuilder.of("registrationName", "onPress")
81 | );
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapPolyline.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.bridge.ReadableArray;
6 | import com.facebook.react.bridge.ReadableMap;
7 | import com.google.android.gms.maps.GoogleMap;
8 | import com.google.android.gms.maps.model.LatLng;
9 | import com.google.android.gms.maps.model.Polyline;
10 | import com.google.android.gms.maps.model.PolylineOptions;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | public class AirMapPolyline extends AirMapFeature {
16 |
17 | private PolylineOptions polylineOptions;
18 | private Polyline polyline;
19 |
20 | private List coordinates;
21 | private int color;
22 | private float width;
23 | private boolean geodesic;
24 | private float zIndex;
25 |
26 | public AirMapPolyline(Context context) {
27 | super(context);
28 | }
29 |
30 | public void setCoordinates(ReadableArray coordinates) {
31 | this.coordinates = new ArrayList<>(coordinates.size());
32 | for (int i = 0; i < coordinates.size(); i++) {
33 | ReadableMap coordinate = coordinates.getMap(i);
34 | this.coordinates.add(i,
35 | new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
36 | }
37 | if (polyline != null) {
38 | polyline.setPoints(this.coordinates);
39 | }
40 | }
41 |
42 | public void setColor(int color) {
43 | this.color = color;
44 | if (polyline != null) {
45 | polyline.setColor(color);
46 | }
47 | }
48 |
49 | public void setWidth(float width) {
50 | this.width = width;
51 | if (polyline != null) {
52 | polyline.setWidth(width);
53 | }
54 | }
55 |
56 | public void setZIndex(float zIndex) {
57 | this.zIndex = zIndex;
58 | if (polyline != null) {
59 | polyline.setZIndex(zIndex);
60 | }
61 | }
62 |
63 | public void setGeodesic(boolean geodesic) {
64 | this.geodesic = geodesic;
65 | if (polyline != null) {
66 | polyline.setGeodesic(geodesic);
67 | }
68 | }
69 |
70 | public PolylineOptions getPolylineOptions() {
71 | if (polylineOptions == null) {
72 | polylineOptions = createPolylineOptions();
73 | }
74 | return polylineOptions;
75 | }
76 |
77 | private PolylineOptions createPolylineOptions() {
78 | PolylineOptions options = new PolylineOptions();
79 | options.addAll(coordinates);
80 | options.color(color);
81 | options.width(width);
82 | options.geodesic(geodesic);
83 | options.zIndex(zIndex);
84 | return options;
85 | }
86 |
87 | @Override
88 | public Object getFeature() {
89 | return polyline;
90 | }
91 |
92 | @Override
93 | public void addToMap(GoogleMap map) {
94 | polyline = map.addPolyline(getPolylineOptions());
95 | polyline.setClickable(false);
96 | }
97 |
98 | @Override
99 | public void removeFromMap(GoogleMap map) {
100 | polyline.remove();
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapPolylineManager.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.util.DisplayMetrics;
7 | import android.view.WindowManager;
8 |
9 | import com.facebook.react.bridge.ReactApplicationContext;
10 | import com.facebook.react.bridge.ReadableArray;
11 | import com.facebook.react.common.MapBuilder;
12 | import com.facebook.react.uimanager.ThemedReactContext;
13 | import com.facebook.react.uimanager.ViewGroupManager;
14 | import com.facebook.react.uimanager.annotations.ReactProp;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 | import javax.annotation.Nullable;
19 |
20 | public class AirMapPolylineManager extends ViewGroupManager {
21 | private final DisplayMetrics metrics;
22 |
23 | public AirMapPolylineManager(ReactApplicationContext reactContext) {
24 | super();
25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
26 | metrics = new DisplayMetrics();
27 | ((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
28 | .getDefaultDisplay()
29 | .getRealMetrics(metrics);
30 | } else {
31 | metrics = reactContext.getResources().getDisplayMetrics();
32 | }
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "AIRMapPolyline";
38 | }
39 |
40 | @Override
41 | public AirMapPolyline createViewInstance(ThemedReactContext context) {
42 | return new AirMapPolyline(context);
43 | }
44 |
45 | @ReactProp(name = "coordinates")
46 | public void setCoordinate(AirMapPolyline view, ReadableArray coordinates) {
47 | view.setCoordinates(coordinates);
48 | }
49 |
50 | @ReactProp(name = "strokeWidth", defaultFloat = 1f)
51 | public void setStrokeWidth(AirMapPolyline view, float widthInPoints) {
52 | float widthInScreenPx = metrics.density * widthInPoints; // done for parity with iOS
53 | view.setWidth(widthInScreenPx);
54 | }
55 |
56 | @ReactProp(name = "strokeColor", defaultInt = Color.RED, customType = "Color")
57 | public void setStrokeColor(AirMapPolyline view, int color) {
58 | view.setColor(color);
59 | }
60 |
61 | @ReactProp(name = "geodesic", defaultBoolean = false)
62 | public void setGeodesic(AirMapPolyline view, boolean geodesic) {
63 | view.setGeodesic(geodesic);
64 | }
65 |
66 | @ReactProp(name = "zIndex", defaultFloat = 1.0f)
67 | public void setZIndex(AirMapPolyline view, float zIndex) {
68 | view.setZIndex(zIndex);
69 | }
70 |
71 | @Override
72 | @Nullable
73 | public Map getExportedCustomDirectEventTypeConstants() {
74 | return MapBuilder.of(
75 | "onPress", MapBuilder.of("registrationName", "onPress")
76 | );
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.android.gms.maps.GoogleMap;
6 | import com.google.android.gms.maps.model.TileOverlay;
7 | import com.google.android.gms.maps.model.TileOverlayOptions;
8 | import com.google.android.gms.maps.model.UrlTileProvider;
9 |
10 | import java.net.MalformedURLException;
11 | import java.net.URL;
12 |
13 | public class AirMapUrlTile extends AirMapFeature {
14 |
15 | class AIRMapUrlTileProvider extends UrlTileProvider
16 | {
17 | private String urlTemplate;
18 | public AIRMapUrlTileProvider(int width, int height, String urlTemplate) {
19 | super(width, height);
20 | this.urlTemplate = urlTemplate;
21 | }
22 | @Override
23 | public synchronized URL getTileUrl(int x, int y, int zoom) {
24 |
25 | String s = this.urlTemplate
26 | .replace("{x}", Integer.toString(x))
27 | .replace("{y}", Integer.toString(y))
28 | .replace("{z}", Integer.toString(zoom));
29 | URL url = null;
30 | try {
31 | url = new URL(s);
32 | } catch (MalformedURLException e) {
33 | throw new AssertionError(e);
34 | }
35 | return url;
36 | }
37 |
38 | public void setUrlTemplate(String urlTemplate) {
39 | this.urlTemplate = urlTemplate;
40 | }
41 | }
42 |
43 | private TileOverlayOptions tileOverlayOptions;
44 | private TileOverlay tileOverlay;
45 | private AIRMapUrlTileProvider tileProvider;
46 |
47 | private String urlTemplate;
48 | private float zIndex;
49 |
50 | public AirMapUrlTile(Context context) {
51 | super(context);
52 | }
53 |
54 | public void setUrlTemplate(String urlTemplate) {
55 | this.urlTemplate = urlTemplate;
56 | if (tileProvider != null) {
57 | tileProvider.setUrlTemplate(urlTemplate);
58 | }
59 | if (tileOverlay != null) {
60 | tileOverlay.clearTileCache();
61 | }
62 | }
63 |
64 | public void setZIndex(float zIndex) {
65 | this.zIndex = zIndex;
66 | if (tileOverlay != null) {
67 | tileOverlay.setZIndex(zIndex);
68 | }
69 | }
70 |
71 | public TileOverlayOptions getTileOverlayOptions() {
72 | if (tileOverlayOptions == null) {
73 | tileOverlayOptions = createTileOverlayOptions();
74 | }
75 | return tileOverlayOptions;
76 | }
77 |
78 | private TileOverlayOptions createTileOverlayOptions() {
79 | TileOverlayOptions options = new TileOverlayOptions();
80 | options.zIndex(zIndex);
81 | this.tileProvider = new AIRMapUrlTileProvider(256, 256, this.urlTemplate);
82 | options.tileProvider(this.tileProvider);
83 | return options;
84 | }
85 |
86 | @Override
87 | public Object getFeature() {
88 | return tileOverlay;
89 | }
90 |
91 | @Override
92 | public void addToMap(GoogleMap map) {
93 | this.tileOverlay = map.addTileOverlay(getTileOverlayOptions());
94 | }
95 |
96 | @Override
97 | public void removeFromMap(GoogleMap map) {
98 | tileOverlay.remove();
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTileManager.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.util.DisplayMetrics;
6 | import android.view.WindowManager;
7 |
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.uimanager.ThemedReactContext;
10 | import com.facebook.react.uimanager.ViewGroupManager;
11 | import com.facebook.react.uimanager.annotations.ReactProp;
12 |
13 | public class AirMapUrlTileManager extends ViewGroupManager {
14 | private DisplayMetrics metrics;
15 |
16 | public AirMapUrlTileManager(ReactApplicationContext reactContext) {
17 | super();
18 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
19 | metrics = new DisplayMetrics();
20 | ((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
21 | .getDefaultDisplay()
22 | .getRealMetrics(metrics);
23 | } else {
24 | metrics = reactContext.getResources().getDisplayMetrics();
25 | }
26 | }
27 |
28 | @Override
29 | public String getName() {
30 | return "AIRMapUrlTile";
31 | }
32 |
33 | @Override
34 | public AirMapUrlTile createViewInstance(ThemedReactContext context) {
35 | return new AirMapUrlTile(context);
36 | }
37 |
38 | @ReactProp(name = "urlTemplate")
39 | public void setUrlTemplate(AirMapUrlTile view, String urlTemplate) {
40 | view.setUrlTemplate(urlTemplate);
41 | }
42 |
43 | @ReactProp(name = "zIndex", defaultFloat = -1.0f)
44 | public void setZIndex(AirMapUrlTile view, float zIndex) {
45 | view.setZIndex(zIndex);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/LatLngBoundsUtils.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import com.google.android.gms.maps.model.LatLng;
4 | import com.google.android.gms.maps.model.LatLngBounds;
5 |
6 | public class LatLngBoundsUtils {
7 | public static boolean BoundsAreDifferent(LatLngBounds a, LatLngBounds b) {
8 | LatLng centerA = a.getCenter();
9 | double latA = centerA.latitude;
10 | double lngA = centerA.longitude;
11 | double latDeltaA = a.northeast.latitude - a.southwest.latitude;
12 | double lngDeltaA = a.northeast.longitude - a.southwest.longitude;
13 |
14 | LatLng centerB = b.getCenter();
15 | double latB = centerB.latitude;
16 | double lngB = centerB.longitude;
17 | double latDeltaB = b.northeast.latitude - b.southwest.latitude;
18 | double lngDeltaB = b.northeast.longitude - b.southwest.longitude;
19 |
20 | double latEps = LatitudeEpsilon(a, b);
21 | double lngEps = LongitudeEpsilon(a, b);
22 |
23 | return
24 | different(latA, latB, latEps) ||
25 | different(lngA, lngB, lngEps) ||
26 | different(latDeltaA, latDeltaB, latEps) ||
27 | different(lngDeltaA, lngDeltaB, lngEps);
28 | }
29 |
30 | private static boolean different(double a, double b, double epsilon) {
31 | return Math.abs(a - b) > epsilon;
32 | }
33 |
34 | private static double LatitudeEpsilon(LatLngBounds a, LatLngBounds b) {
35 | double sizeA = a.northeast.latitude - a.southwest.latitude; // something mod 180?
36 | double sizeB = b.northeast.latitude - b.southwest.latitude; // something mod 180?
37 | double size = Math.min(Math.abs(sizeA), Math.abs(sizeB));
38 | return size / 2560;
39 | }
40 |
41 | private static double LongitudeEpsilon(LatLngBounds a, LatLngBounds b) {
42 | double sizeA = a.northeast.longitude - a.southwest.longitude;
43 | double sizeB = b.northeast.longitude - b.southwest.longitude;
44 | double size = Math.min(Math.abs(sizeA), Math.abs(sizeB));
45 | return size / 2560;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/MapsPackage.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import android.app.Activity;
4 |
5 | import com.facebook.react.ReactPackage;
6 | import com.facebook.react.bridge.JavaScriptModule;
7 | import com.facebook.react.bridge.NativeModule;
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.uimanager.ViewManager;
10 |
11 | import java.util.Arrays;
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class MapsPackage implements ReactPackage {
16 | public MapsPackage(Activity activity) {
17 | } // backwards compatability
18 |
19 | public MapsPackage() {
20 | }
21 |
22 | @Override
23 | public List createNativeModules(ReactApplicationContext reactContext) {
24 | return Arrays.asList(new AirMapModule(reactContext),
25 | new MapsUtilsModule(reactContext));
26 | }
27 |
28 | @Override
29 | public List> createJSModules() {
30 | return Collections.emptyList();
31 | }
32 |
33 | @Override
34 | public List createViewManagers(ReactApplicationContext reactContext) {
35 | AirMapCalloutManager calloutManager = new AirMapCalloutManager();
36 | AirMapMarkerManager annotationManager = new AirMapMarkerManager();
37 | AirMapPolylineManager polylineManager = new AirMapPolylineManager(reactContext);
38 | AirMapPolygonManager polygonManager = new AirMapPolygonManager(reactContext);
39 | AirMapCircleManager circleManager = new AirMapCircleManager(reactContext);
40 | AirMapManager mapManager = new AirMapManager(reactContext);
41 | AirMapLiteManager mapLiteManager = new AirMapLiteManager(reactContext);
42 | AirMapUrlTileManager tileManager = new AirMapUrlTileManager(reactContext);
43 |
44 | return Arrays.asList(
45 | calloutManager,
46 | annotationManager,
47 | polylineManager,
48 | polygonManager,
49 | circleManager,
50 | mapManager,
51 | mapLiteManager,
52 | tileManager);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/MapsUtilsModule.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import com.facebook.react.bridge.Callback;
4 | import com.facebook.react.bridge.Promise;
5 | import com.facebook.react.bridge.ReactApplicationContext;
6 | import com.facebook.react.bridge.ReactMethod;
7 |
8 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
9 | import com.facebook.react.bridge.ReadableArray;
10 | import com.facebook.react.bridge.WritableNativeArray;
11 | import com.google.android.gms.maps.model.LatLng;
12 | import com.google.maps.android.SphericalUtil;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class MapsUtilsModule extends ReactContextBaseJavaModule {
17 | public MapsUtilsModule(ReactApplicationContext reactContext) {
18 | super(reactContext);
19 | }
20 |
21 | @Override
22 | public String getName() {
23 | return "MapsUtilsModule";
24 | }
25 |
26 | private List polylineCoordsToLatLngList(ReadableArray polylineCoords) {
27 | ArrayList list = new ArrayList();
28 |
29 | for(int i = 0; i < polylineCoords.size(); i++) {
30 | ReadableArray coord = polylineCoords.getArray(i);
31 |
32 | list.add(new LatLng(coord.getDouble(0), coord.getDouble(1)));
33 | }
34 |
35 | return list;
36 | }
37 |
38 | private LatLng latlngFromReadableArray(ReadableArray coordinate) {
39 | return new LatLng(coordinate.getDouble(0), coordinate.getDouble(1));
40 | }
41 |
42 | @ReactMethod
43 | public void indexOfLocationOnPolyline(ReadableArray coordinate, ReadableArray polylineCoords, double toleranceMeters, Callback callback) {
44 | List polylineCoordsList = this.polylineCoordsToLatLngList(polylineCoords);
45 |
46 | int index = PolyUtils.locationIndexOnEdgeOrPath(new LatLng(coordinate.getDouble(0), coordinate.getDouble(1)),
47 | polylineCoordsList,
48 | false,
49 | false,
50 | toleranceMeters);
51 |
52 | callback.invoke(index);
53 | }
54 |
55 | @ReactMethod
56 | public void computeOffset(ReadableArray from, double distance, double heading, Promise promise) {
57 | LatLng fromCoord = this.latlngFromReadableArray(from);
58 | LatLng offsetCoord = SphericalUtil.computeOffset(fromCoord, distance, heading);
59 | WritableNativeArray coords = new WritableNativeArray();
60 | coords.pushDouble(offsetCoord.latitude);
61 | coords.pushDouble(offsetCoord.longitude);
62 |
63 | promise.resolve(coords);
64 | }
65 | /**
66 | * Returns haversine(angle-in-radians).
67 | * hav(x) == (1 - cos(x)) / 2 == sin(x / 2)^2.
68 | */
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/RegionChangeEvent.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps;
2 |
3 | import com.facebook.react.bridge.WritableMap;
4 | import com.facebook.react.bridge.WritableNativeMap;
5 | import com.facebook.react.uimanager.events.Event;
6 | import com.facebook.react.uimanager.events.RCTEventEmitter;
7 | import com.google.android.gms.maps.model.LatLng;
8 | import com.google.android.gms.maps.model.LatLngBounds;
9 |
10 | public class RegionChangeEvent extends Event {
11 | private final LatLngBounds bounds;
12 | private final LatLng center;
13 | private final boolean continuous;
14 |
15 | public RegionChangeEvent(int id, LatLngBounds bounds, LatLng center, boolean continuous) {
16 | super(id);
17 | this.bounds = bounds;
18 | this.center = center;
19 | this.continuous = continuous;
20 | }
21 |
22 | @Override
23 | public String getEventName() {
24 | return "topChange";
25 | }
26 |
27 | @Override
28 | public boolean canCoalesce() {
29 | return false;
30 | }
31 |
32 | @Override
33 | public void dispatch(RCTEventEmitter rctEventEmitter) {
34 |
35 | WritableMap event = new WritableNativeMap();
36 | event.putBoolean("continuous", continuous);
37 |
38 | WritableMap region = new WritableNativeMap();
39 | region.putDouble("latitude", center.latitude);
40 | region.putDouble("longitude", center.longitude);
41 | region.putDouble("latitudeDelta", bounds.northeast.latitude - bounds.southwest.latitude);
42 | region.putDouble("longitudeDelta", bounds.northeast.longitude - bounds.southwest.longitude);
43 | event.putMap("region", region);
44 |
45 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), event);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/android/src/main/java/com/airbnb/android/react/maps/SizeReportingShadowNode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | * This source code is licensed under the BSD-style license found in the
5 | * LICENSE file in the root directory of this source tree. An additional grant
6 | * of patent rights can be found in the PATENTS file in the same directory.
7 | */
8 |
9 | package com.airbnb.android.react.maps;
10 |
11 | import com.facebook.react.uimanager.LayoutShadowNode;
12 | import com.facebook.react.uimanager.UIViewOperationQueue;
13 |
14 | import java.util.HashMap;
15 | import java.util.Map;
16 |
17 | // Custom LayoutShadowNode implementation used in conjunction with the AirMapManager
18 | // which sends the width/height of the view after layout occurs.
19 | public class SizeReportingShadowNode extends LayoutShadowNode {
20 |
21 | @Override
22 | public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
23 | super.onCollectExtraUpdates(uiViewOperationQueue);
24 |
25 | Map data = new HashMap<>();
26 | data.put("width", getLayoutWidth());
27 | data.put("height", getLayoutHeight());
28 |
29 | uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), data);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/components/MapCallout.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 | import {
3 | View,
4 | StyleSheet,
5 | } from 'react-native';
6 | import decorateMapComponent, {
7 | SUPPORTED,
8 | USES_DEFAULT_IMPLEMENTATION,
9 | } from './decorateMapComponent';
10 |
11 | const propTypes = {
12 | ...View.propTypes,
13 | tooltip: PropTypes.bool,
14 | onPress: PropTypes.func,
15 | };
16 |
17 | const defaultProps = {
18 | tooltip: false,
19 | };
20 |
21 | class MapCallout extends React.Component {
22 | render() {
23 | const AIRMapCallout = this.getAirComponent();
24 | return ;
25 | }
26 | }
27 |
28 | MapCallout.propTypes = propTypes;
29 | MapCallout.defaultProps = defaultProps;
30 |
31 | const styles = StyleSheet.create({
32 | callout: {
33 | position: 'absolute',
34 | },
35 | });
36 |
37 | module.exports = decorateMapComponent(MapCallout, {
38 | componentType: 'Callout',
39 | providers: {
40 | google: {
41 | ios: SUPPORTED,
42 | android: USES_DEFAULT_IMPLEMENTATION,
43 | },
44 | },
45 | });
46 |
--------------------------------------------------------------------------------
/components/MapUrlTile.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 |
3 | import {
4 | View,
5 | } from 'react-native';
6 |
7 | import decorateMapComponent, {
8 | USES_DEFAULT_IMPLEMENTATION,
9 | SUPPORTED,
10 | } from './decorateMapComponent';
11 |
12 | const propTypes = {
13 | ...View.propTypes,
14 |
15 | /**
16 | * The url template of the tile server. The patterns {x} {y} {z} will be replaced at runtime
17 | * For example, http://c.tile.openstreetmap.org/{z}/{x}/{y}.png
18 | */
19 | urlTemplate: PropTypes.string.isRequired,
20 |
21 | /**
22 | * The order in which this tile overlay is drawn with respect to other overlays. An overlay
23 | * with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays
24 | * with the same z-index is arbitrary. The default zIndex is -1.
25 | *
26 | * @platform android
27 | */
28 | zIndex: PropTypes.number,
29 | };
30 |
31 | class MapUrlTile extends React.Component {
32 | render() {
33 | const AIRMapUrlTile = this.getAirComponent();
34 | return (
35 |
38 | );
39 | }
40 | }
41 |
42 | MapUrlTile.propTypes = propTypes;
43 |
44 | module.exports = decorateMapComponent(MapUrlTile, {
45 | componentType: 'UrlTile',
46 | providers: {
47 | google: {
48 | ios: SUPPORTED,
49 | android: USES_DEFAULT_IMPLEMENTATION,
50 | },
51 | },
52 | });
53 |
--------------------------------------------------------------------------------
/components/MapUtils.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/components/MapUtils.js
--------------------------------------------------------------------------------
/components/ProviderConstants.js:
--------------------------------------------------------------------------------
1 | export const PROVIDER_DEFAULT = null;
2 | export const PROVIDER_GOOGLE = 'google';
3 |
--------------------------------------------------------------------------------
/components/decorateMapComponent.js:
--------------------------------------------------------------------------------
1 | import { PropTypes } from 'react';
2 | import {
3 | requireNativeComponent,
4 | NativeModules,
5 | Platform,
6 | } from 'react-native';
7 | import {
8 | PROVIDER_DEFAULT,
9 | PROVIDER_GOOGLE,
10 | } from './ProviderConstants';
11 |
12 | export const SUPPORTED = 'SUPPORTED';
13 | export const USES_DEFAULT_IMPLEMENTATION = 'USES_DEFAULT_IMPLEMENTATION';
14 | export const NOT_SUPPORTED = 'NOT_SUPPORTED';
15 |
16 | export function getAirMapName(provider) {
17 | if (Platform.OS === 'android') return 'AIRMap';
18 | if (provider === PROVIDER_GOOGLE) return 'AIRGoogleMap';
19 | return 'AIRMap';
20 | }
21 |
22 | function getAirComponentName(provider, component) {
23 | return `${getAirMapName(provider)}${component}`;
24 | }
25 |
26 | export const contextTypes = {
27 | provider: PropTypes.string,
28 | };
29 |
30 | export const createNotSupportedComponent = message => () => {
31 | console.error(message); // eslint-disable-line no-console
32 | return null;
33 | };
34 |
35 | export const googleMapIsInstalled = !!NativeModules.UIManager[getAirMapName(PROVIDER_GOOGLE)];
36 |
37 | export default function decorateMapComponent(Component, { componentType, providers }) {
38 | const components = {};
39 |
40 | const getDefaultComponent = () =>
41 | requireNativeComponent(getAirComponentName(null, componentType), Component);
42 |
43 | Component.contextTypes = contextTypes; // eslint-disable-line no-param-reassign
44 |
45 | // eslint-disable-next-line no-param-reassign
46 | Component.prototype.getAirComponent = function getAirComponent() {
47 | const provider = this.context.provider || PROVIDER_DEFAULT;
48 | if (components[provider]) return components[provider];
49 |
50 | if (provider === PROVIDER_DEFAULT) {
51 | components[PROVIDER_DEFAULT] = getDefaultComponent();
52 | return components[PROVIDER_DEFAULT];
53 | }
54 |
55 | const providerInfo = providers[provider];
56 | const platformSupport = providerInfo[Platform.OS];
57 | const componentName = getAirComponentName(provider, componentType);
58 | if (platformSupport === NOT_SUPPORTED) {
59 | components[provider] = createNotSupportedComponent(`react-native-maps: ${componentName} is not supported on ${Platform.OS}`); // eslint-disable-line max-len
60 | } else if (platformSupport === SUPPORTED) {
61 | if (provider !== PROVIDER_GOOGLE || (Platform.OS === 'ios' && googleMapIsInstalled)) {
62 | components[provider] = requireNativeComponent(componentName, Component);
63 | }
64 | } else { // (platformSupport === USES_DEFAULT_IMPLEMENTATION)
65 | if (!components[PROVIDER_DEFAULT]) components[PROVIDER_DEFAULT] = getDefaultComponent();
66 | components[provider] = components[PROVIDER_DEFAULT];
67 | }
68 |
69 | return components[provider];
70 | };
71 |
72 | Component.prototype.getUIManagerCommand = function getUIManagerCommand(name) { // eslint-disable-line no-param-reassign,max-len
73 | return NativeModules.UIManager[getAirComponentName(this.context.provider, componentType)]
74 | .Commands[name];
75 | };
76 |
77 | Component.prototype.getMapManagerCommand = function getMapManagerCommand(name) { // eslint-disable-line no-param-reassign,max-len
78 | const airComponentName = `${getAirComponentName(this.context.provider, componentType)}Manager`;
79 | return NativeModules[airComponentName][name];
80 | };
81 |
82 | return Component;
83 | }
84 |
--------------------------------------------------------------------------------
/docs/callout.md:
--------------------------------------------------------------------------------
1 | # `` Component API
2 |
3 | ## Props
4 |
5 | | Prop | Type | Default | Note |
6 | |---|---|---|---|
7 | | `tooltip` | `Boolean` | `false` | If `false`, a default "tooltip" bubble window will be drawn around this callouts children. If `true`, the child views can fully customize their appearance, including any "bubble" like styles.
8 |
9 |
10 | ## Events
11 |
12 | | Event Name | Returns | Notes
13 | |---|---|---|
14 | | `onPress` | | Callback that is called when the user presses on the callout
15 |
--------------------------------------------------------------------------------
/docs/circle.md:
--------------------------------------------------------------------------------
1 | # `` Component API
2 |
3 | ## Props
4 |
5 | | Prop | Type | Default | Note |
6 | |---|---|---|---|
7 | | `center` | `LatLng` | (Required) | The coordinate of the center of the circle
8 | | `radius` | `Number` | (Required) | The radius of the circle to be drawn (in meters)
9 | | `strokeWidth` | `Number` | `1` | The stroke width to use for the path.
10 | | `strokeColor` | `String` | `#000` | The stroke color to use for the path.
11 | | `fillColor` | `String` | | The fill color to use for the path.
12 | | `zIndex` | `Number` | 0 | The order in which this tile overlay is drawn with respect to other overlays. An overlay with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays with the same z-index is arbitrary. The default zIndex is 0. (Android Only)
13 | | `lineCap` | `String` | `round` | The line cap style to apply to the open ends of the path.
14 | | `lineJoin` | `Array` | | The line join style to apply to corners of the path.
15 | | `miterLimit` | `Number` | | The limiting value that helps avoid spikes at junctions between connected line segments. The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
16 | | `geodesic` | `Boolean` | | Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to straight lines on the Mercator projection. A geodesic is the shortest path between two points on the Earth's surface. The geodesic curve is constructed assuming the Earth is a sphere.
17 | | `lineDashPhase` | `Number` | `0` | (iOS only) The offset (in points) at which to start drawing the dash pattern. Use this property to start drawing a dashed line partway through a segment or gap. For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
18 | | `lineDashPattern` | `Array` | `null` | (iOS only) An array of numbers specifying the dash pattern to use for the path. The array contains one or more numbers that indicate the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
19 |
20 |
21 | ## Types
22 |
23 | ```
24 | type LatLng {
25 | latitude: Number,
26 | longitude: Number,
27 | }
28 | ```
29 |
--------------------------------------------------------------------------------
/docs/examples-setup.md:
--------------------------------------------------------------------------------
1 | # Examples Setup
2 |
3 | ## iOS
4 |
5 | 1. If you don't have bundler gem installed:
6 |
7 | ```
8 | gem install bundler
9 | ```
10 |
11 | 2. Install dependencies and open the workspace:
12 |
13 | ```
14 | cd example
15 | npm install
16 | cd ios
17 | bundle install
18 | bundle exec pod install
19 | open AirMapsExplorer.xcworkspace
20 | ```
21 |
22 | 3. Make sure the `AirMapsExplorer` target is selected and click `Run`
23 |
24 | ## android
25 |
26 | 1. Start your emulator
27 |
28 | 2. Install via gradle:
29 |
30 | ```
31 | # from the example/ dir:
32 | react-native run-android
33 | ```
34 |
--------------------------------------------------------------------------------
/docs/polygon.md:
--------------------------------------------------------------------------------
1 | # `` Component API
2 |
3 | ## Props
4 |
5 | | Prop | Type | Default | Note |
6 | |---|---|---|---|
7 | | `coordinates` | `Array` | (Required) | An array of coordinates to describe the polygon
8 | | `strokeWidth` | `Number` | `1` | The stroke width to use for the path.
9 | | `strokeColor` | `String` | `#000` | The stroke color to use for the path.
10 | | `fillColor` | `String` | | The fill color to use for the path.
11 | | `lineCap` | `String` | `round` | The line cap style to apply to the open ends of the path.
12 | | `lineJoin` | `Array` | | The line join style to apply to corners of the path.
13 | | `miterLimit` | `Number` | | The limiting value that helps avoid spikes at junctions between connected line segments. The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
14 | | `geodesic` | `Boolean` | | Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to straight lines on the Mercator projection. A geodesic is the shortest path between two points on the Earth's surface. The geodesic curve is constructed assuming the Earth is a sphere.
15 | | `lineDashPhase` | `Number` | `0` | (iOS only) The offset (in points) at which to start drawing the dash pattern. Use this property to start drawing a dashed line partway through a segment or gap. For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
16 | | `lineDashPattern` | `Array` | `null` | (iOS only) An array of numbers specifying the dash pattern to use for the path. The array contains one or more numbers that indicate the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
17 |
18 | ## Events
19 |
20 | | Event Name | Returns | Notes
21 | |---|---|---|
22 | | `onPress` | | Callback that is called when the user presses on the polygon
23 |
24 | ## Types
25 |
26 | ```
27 | type LatLng {
28 | latitude: Number,
29 | longitude: Number,
30 | }
31 | ```
32 |
--------------------------------------------------------------------------------
/docs/polyline.md:
--------------------------------------------------------------------------------
1 | # `` Component API
2 |
3 | ## Props
4 |
5 | | Prop | Type | Default | Note |
6 | |---|---|---|---|
7 | | `coordinates` | `Array` | (Required) | An array of coordinates to describe the polyline
8 | | `strokeWidth` | `Number` | `1` | The stroke width to use for the path.
9 | | `strokeColor` | `String` | `#000` | The stroke color to use for the path.
10 | | `lineCap` | `String` | `round` | The line cap style to apply to the open ends of the path.
11 | | `lineJoin` | `Array` | | The line join style to apply to corners of the path.
12 | | `miterLimit` | `Number` | | The limiting value that helps avoid spikes at junctions between connected line segments. The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
13 | | `geodesic` | `Boolean` | | Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to straight lines on the Mercator projection. A geodesic is the shortest path between two points on the Earth's surface. The geodesic curve is constructed assuming the Earth is a sphere.
14 | | `lineDashPhase` | `Number` | `0` | (iOS only) The offset (in points) at which to start drawing the dash pattern. Use this property to start drawing a dashed line partway through a segment or gap. For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
15 | | `lineDashPattern` | `Array` | `null` | (iOS only) An array of numbers specifying the dash pattern to use for the path. The array contains one or more numbers that indicate the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
16 |
17 | ## Events
18 |
19 | | Event Name | Returns | Notes
20 | |---|---|---|
21 | | `onPress` | | Callback that is called when the user presses on the polyline
22 |
23 | ## Types
24 |
25 | ```
26 | type LatLng {
27 | latitude: Number,
28 | longitude: Number,
29 | }
30 | ```
31 |
--------------------------------------------------------------------------------
/example/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-console": 0
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/example/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 |
3 | # We fork some components by platform.
4 | .*/*.web.js
5 | .*/*.android.js
6 |
7 | # Some modules have their own node_modules with overlap
8 | .*/node_modules/node-haste/.*
9 |
10 | # Ugh
11 | .*/node_modules/babel.*
12 | .*/node_modules/babylon.*
13 | .*/node_modules/invariant.*
14 |
15 | # Ignore react and fbjs where there are overlaps, but don't ignore
16 | # anything that react-native relies on
17 | .*/node_modules/fbjs/lib/Map.js
18 | .*/node_modules/fbjs/lib/Promise.js
19 | .*/node_modules/fbjs/lib/fetch.js
20 | .*/node_modules/fbjs/lib/ExecutionEnvironment.js
21 | .*/node_modules/fbjs/lib/isEmpty.js
22 | .*/node_modules/fbjs/lib/crc32.js
23 | .*/node_modules/fbjs/lib/ErrorUtils.js
24 |
25 | # Flow has a built-in definition for the 'react' module which we prefer to use
26 | # over the currently-untyped source
27 | .*/node_modules/react/react.js
28 | .*/node_modules/react/lib/React.js
29 | .*/node_modules/react/lib/ReactDOM.js
30 |
31 | # Ignore commoner tests
32 | .*/node_modules/commoner/test/.*
33 |
34 | # See https://github.com/facebook/flow/issues/442
35 | .*/react-tools/node_modules/commoner/lib/reader.js
36 |
37 | # Ignore jest
38 | .*/node_modules/jest-cli/.*
39 |
40 | # Ignore Website
41 | .*/website/.*
42 |
43 | [include]
44 |
45 | [libs]
46 | node_modules/react-native/Libraries/react-native/react-native-interface.js
47 |
48 | [options]
49 | module.system=haste
50 |
51 | munge_underscores=true
52 |
53 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
54 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'
55 |
56 | suppress_type=$FlowIssue
57 | suppress_type=$FlowFixMe
58 | suppress_type=$FixMe
59 |
60 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
61 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
62 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
63 |
64 | [version]
65 | 0.21.0
66 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | project.xcworkspace
24 |
25 | # Android/IJ
26 | #
27 | .idea
28 | .gradle
29 | local.properties
30 |
31 | # node.js
32 | #
33 | node_modules/
34 | npm-debug.log
35 |
--------------------------------------------------------------------------------
/example/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Disabling obfuscation is useful if you collect stack traces from production crashes
20 | # (unless you are using a system that supports de-obfuscate the stack traces).
21 | -dontobfuscate
22 |
23 | # React Native
24 |
25 | # Keep our interfaces so they can be used by other ProGuard rules.
26 | # See http://sourceforge.net/p/proguard/bugs/466/
27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29 |
30 | # Do not strip any method/class that is annotated with @DoNotStrip
31 | -keep @com.facebook.proguard.annotations.DoNotStrip class *
32 | -keepclassmembers class * {
33 | @com.facebook.proguard.annotations.DoNotStrip *;
34 | }
35 |
36 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
37 | void set*(***);
38 | *** get*();
39 | }
40 |
41 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
42 | -keep class * extends com.facebook.react.bridge.NativeModule { *; }
43 | -keepclassmembers,includedescriptorclasses class * { native ; }
44 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; }
45 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; }
46 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; }
47 |
48 | -dontwarn com.facebook.react.**
49 |
50 | # okhttp
51 |
52 | -keepattributes Signature
53 | -keepattributes *Annotation*
54 | -keep class com.squareup.okhttp.** { *; }
55 | -keep interface com.squareup.okhttp.** { *; }
56 | -dontwarn com.squareup.okhttp.**
57 |
58 | # okio
59 |
60 | -keep class sun.misc.Unsafe { *; }
61 | -dontwarn java.nio.file.*
62 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
63 | -dontwarn okio.**
64 |
65 | # stetho
66 |
67 | -dontwarn com.facebook.stetho.**
68 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/airbnb/android/react/maps/example/ExampleApplication.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps.example;
2 |
3 | import android.app.Application;
4 |
5 | import com.airbnb.android.react.maps.MapsPackage;
6 | import com.facebook.react.ReactApplication;
7 | import com.facebook.react.ReactNativeHost;
8 | import com.facebook.react.ReactPackage;
9 | import com.facebook.react.shell.MainReactPackage;
10 |
11 | import java.util.Arrays;
12 | import java.util.List;
13 |
14 | public class ExampleApplication extends Application implements ReactApplication {
15 | private final ReactNativeHost reactNativeHost = new ReactNativeHost(this) {
16 | @Override public boolean getUseDeveloperSupport() {
17 | return BuildConfig.DEBUG;
18 | }
19 | @Override protected List getPackages() {
20 | return Arrays.asList(
21 | new MainReactPackage(),
22 | new MapsPackage());
23 | }
24 | };
25 |
26 | @Override
27 | public ReactNativeHost getReactNativeHost() {
28 | return reactNativeHost;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/airbnb/android/react/maps/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.airbnb.android.react.maps.example;
2 |
3 | import com.facebook.react.ReactActivity;
4 |
5 |
6 | public class MainActivity extends ReactActivity {
7 |
8 | /**
9 | * Returns the name of the main component registered from JavaScript.
10 | * This is used to schedule rendering of the component.
11 | */
12 | @Override
13 | protected String getMainComponentName() {
14 | return "AirMapsExplorer";
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AirMapsExplorer
3 |
4 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.1'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | mavenLocal()
18 | jcenter()
19 | maven {
20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21 | url "$projectDir/../../node_modules/react-native/android"
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Sep 08 17:18:44 BRT 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':react-native-maps'
2 | project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')
3 |
--------------------------------------------------------------------------------
/example/examples/AnimatedMarkers.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | TouchableOpacity,
8 | Animated,
9 | } from 'react-native';
10 |
11 | import MapView from 'react-native-maps';
12 |
13 | const screen = Dimensions.get('window');
14 |
15 | const ASPECT_RATIO = screen.width / screen.height;
16 | const LATITUDE = 37.78825;
17 | const LONGITUDE = -122.4324;
18 | const LATITUDE_DELTA = 0.0922;
19 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
20 |
21 | class AnimatedMarkers extends React.Component {
22 | constructor(props) {
23 | super(props);
24 |
25 | this.state = {
26 | coordinate: new Animated.Region({
27 | latitude: LATITUDE,
28 | longitude: LONGITUDE,
29 | }),
30 | };
31 | }
32 |
33 | animate() {
34 | const { coordinate } = this.state;
35 | coordinate.timing({
36 | latitude: LATITUDE + ((Math.random() - 0.5) * (LATITUDE_DELTA / 2)),
37 | longitude: LONGITUDE + ((Math.random() - 0.5) * (LONGITUDE_DELTA / 2)),
38 | }).start();
39 | }
40 |
41 | render() {
42 | return (
43 |
44 |
54 |
57 |
58 |
59 |
63 | Animate
64 |
65 |
66 |
67 | );
68 | }
69 | }
70 |
71 | AnimatedMarkers.propTypes = {
72 | provider: MapView.ProviderPropType,
73 | };
74 |
75 | const styles = StyleSheet.create({
76 | container: {
77 | ...StyleSheet.absoluteFillObject,
78 | justifyContent: 'flex-end',
79 | alignItems: 'center',
80 | },
81 | map: {
82 | ...StyleSheet.absoluteFillObject,
83 | },
84 | bubble: {
85 | flex: 1,
86 | backgroundColor: 'rgba(255,255,255,0.7)',
87 | paddingHorizontal: 18,
88 | paddingVertical: 12,
89 | borderRadius: 20,
90 | },
91 | latlng: {
92 | width: 200,
93 | alignItems: 'stretch',
94 | },
95 | button: {
96 | width: 80,
97 | paddingHorizontal: 12,
98 | alignItems: 'center',
99 | marginHorizontal: 10,
100 | },
101 | buttonContainer: {
102 | flexDirection: 'row',
103 | marginVertical: 20,
104 | backgroundColor: 'transparent',
105 | },
106 | });
107 |
108 | module.exports = AnimatedMarkers;
109 |
--------------------------------------------------------------------------------
/example/examples/AnimatedPriceMarker.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 | import {
3 | StyleSheet,
4 | Text,
5 | Animated,
6 | } from 'react-native';
7 |
8 | class AnimatedPriceMarker extends React.Component {
9 | render() {
10 | const { amount, selected, style } = this.props;
11 |
12 | const background = selected.interpolate({
13 | inputRange: [0, 1],
14 | outputRange: ['#FF5A5F', '#4da2ab'],
15 | });
16 |
17 | const border = selected.interpolate({
18 | inputRange: [0, 1],
19 | outputRange: ['#D23F44', '#007a87'],
20 | });
21 |
22 | return (
23 |
24 |
33 | $
34 | {amount}
35 |
36 |
39 |
42 |
43 | );
44 | }
45 | }
46 |
47 | AnimatedPriceMarker.propTypes = {
48 | amount: PropTypes.number.isRequired,
49 | selected: PropTypes.object.isRequired,
50 | style: PropTypes.any,
51 | };
52 |
53 | const styles = StyleSheet.create({
54 | container: {
55 | flexDirection: 'column',
56 | alignSelf: 'flex-start',
57 | },
58 | bubble: {
59 | flex: 0,
60 | flexDirection: 'row',
61 | alignSelf: 'flex-start',
62 | backgroundColor: '#FF5A5F',
63 | paddingVertical: 2,
64 | paddingHorizontal: 4,
65 | borderRadius: 3,
66 | borderColor: '#D23F44',
67 | borderWidth: 0.5,
68 | },
69 | dollar: {
70 | color: '#fff',
71 | fontSize: 10,
72 | },
73 | amount: {
74 | color: '#fff',
75 | fontSize: 13,
76 | },
77 | arrow: {
78 | backgroundColor: 'transparent',
79 | borderColor: 'transparent',
80 | borderWidth: 4,
81 | borderTopColor: '#FF5A5F',
82 | alignSelf: 'center',
83 | marginTop: -9,
84 | },
85 | arrowBorder: {
86 | backgroundColor: 'transparent',
87 | borderColor: 'transparent',
88 | borderWidth: 4,
89 | borderTopColor: '#D23F44',
90 | alignSelf: 'center',
91 | marginTop: -0.5,
92 | },
93 | selectedBubble: {
94 | backgroundColor: '#4da2ab',
95 | borderColor: '#007a87',
96 | },
97 | selectedArrow: {
98 | borderTopColor: '#4da2ab',
99 |
100 | },
101 | selectedArrowBorder: {
102 | borderTopColor: '#007a87',
103 | },
104 | });
105 |
106 | module.exports = AnimatedPriceMarker;
107 |
--------------------------------------------------------------------------------
/example/examples/CustomCallout.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | } from 'react-native';
6 |
7 | const propTypes = {
8 | children: PropTypes.node.isRequired,
9 | style: PropTypes.object,
10 | };
11 |
12 | class CustomCallout extends React.Component {
13 | render() {
14 | return (
15 |
16 |
17 |
18 | {this.props.children}
19 |
20 |
21 |
22 |
23 |
24 | );
25 | }
26 | }
27 |
28 | CustomCallout.propTypes = propTypes;
29 |
30 | const styles = StyleSheet.create({
31 | container: {
32 | flexDirection: 'column',
33 | alignSelf: 'flex-start',
34 | },
35 | bubble: {
36 | width: 140,
37 | flexDirection: 'row',
38 | alignSelf: 'flex-start',
39 | backgroundColor: '#4da2ab',
40 | paddingHorizontal: 20,
41 | paddingVertical: 12,
42 | borderRadius: 6,
43 | borderColor: '#007a87',
44 | borderWidth: 0.5,
45 | },
46 | amount: {
47 | flex: 1,
48 | },
49 | arrow: {
50 | backgroundColor: 'transparent',
51 | borderWidth: 16,
52 | borderColor: 'transparent',
53 | borderTopColor: '#4da2ab',
54 | alignSelf: 'center',
55 | marginTop: -32,
56 | },
57 | arrowBorder: {
58 | backgroundColor: 'transparent',
59 | borderWidth: 16,
60 | borderColor: 'transparent',
61 | borderTopColor: '#007a87',
62 | alignSelf: 'center',
63 | marginTop: -0.5,
64 | },
65 | });
66 |
67 | module.exports = CustomCallout;
68 |
--------------------------------------------------------------------------------
/example/examples/CustomMarkers.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | TouchableOpacity,
8 | } from 'react-native';
9 |
10 | import MapView from 'react-native-maps';
11 | import flagPinkImg from './assets/flag-pink.png';
12 |
13 | const { width, height } = Dimensions.get('window');
14 |
15 | const ASPECT_RATIO = width / height;
16 | const LATITUDE = 37.78825;
17 | const LONGITUDE = -122.4324;
18 | const LATITUDE_DELTA = 0.0922;
19 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
20 | let id = 0;
21 |
22 | class CustomMarkers extends React.Component {
23 | constructor(props) {
24 | super(props);
25 |
26 | this.state = {
27 | region: {
28 | latitude: LATITUDE,
29 | longitude: LONGITUDE,
30 | latitudeDelta: LATITUDE_DELTA,
31 | longitudeDelta: LONGITUDE_DELTA,
32 | },
33 | markers: [],
34 | };
35 |
36 | this.onMapPress = this.onMapPress.bind(this);
37 | }
38 |
39 | onMapPress(e) {
40 | this.setState({
41 | markers: [
42 | ...this.state.markers,
43 | {
44 | coordinate: e.nativeEvent.coordinate,
45 | key: `foo${id++}`,
46 | },
47 | ],
48 | });
49 | }
50 |
51 | render() {
52 | return (
53 |
54 |
60 | {this.state.markers.map(marker => (
61 |
67 | ))}
68 |
69 |
70 | this.setState({ markers: [] })}
72 | style={styles.bubble}
73 | >
74 | Tap to create a marker of random color
75 |
76 |
77 |
78 | );
79 | }
80 | }
81 |
82 | CustomMarkers.propTypes = {
83 | provider: MapView.ProviderPropType,
84 | };
85 |
86 | const styles = StyleSheet.create({
87 | container: {
88 | ...StyleSheet.absoluteFillObject,
89 | justifyContent: 'flex-end',
90 | alignItems: 'center',
91 | },
92 | map: {
93 | ...StyleSheet.absoluteFillObject,
94 | },
95 | bubble: {
96 | backgroundColor: 'rgba(255,255,255,0.7)',
97 | paddingHorizontal: 18,
98 | paddingVertical: 12,
99 | borderRadius: 20,
100 | },
101 | latlng: {
102 | width: 200,
103 | alignItems: 'stretch',
104 | },
105 | button: {
106 | width: 80,
107 | paddingHorizontal: 12,
108 | alignItems: 'center',
109 | marginHorizontal: 10,
110 | },
111 | buttonContainer: {
112 | flexDirection: 'row',
113 | marginVertical: 20,
114 | backgroundColor: 'transparent',
115 | },
116 | });
117 |
118 | module.exports = CustomMarkers;
119 |
--------------------------------------------------------------------------------
/example/examples/CustomOverlay.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Dimensions,
6 | } from 'react-native';
7 |
8 | import MapView from 'react-native-maps';
9 | import XMarksTheSpot from './CustomOverlayXMarksTheSpot';
10 |
11 | const { width, height } = Dimensions.get('window');
12 | const ASPECT_RATIO = width / height;
13 | const LATITUDE = 37.78825;
14 | const LONGITUDE = -122.4324;
15 | const LATITUDE_DELTA = 0.0922;
16 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
17 |
18 | class CustomOverlay extends React.Component {
19 | constructor(props) {
20 | super(props);
21 |
22 | this.state = {
23 | region: {
24 | latitude: LATITUDE,
25 | longitude: LONGITUDE,
26 | latitudeDelta: LATITUDE_DELTA,
27 | longitudeDelta: LONGITUDE_DELTA,
28 | },
29 | coordinates: [
30 | {
31 | longitude: -122.442753,
32 | latitude: 37.798790,
33 | },
34 | {
35 | longitude: -122.424728,
36 | latitude: 37.801232,
37 | },
38 | {
39 | longitude: -122.422497,
40 | latitude: 37.790651,
41 | },
42 | {
43 | longitude: -122.440693,
44 | latitude: 37.788209,
45 | },
46 | ],
47 | center: {
48 | longitude: -122.4326648935676,
49 | latitude: 37.79418561114521,
50 | },
51 | };
52 | }
53 |
54 | render() {
55 | const { coordinates, center, region } = this.state;
56 | return (
57 |
58 |
63 |
64 |
65 |
66 | );
67 | }
68 | }
69 |
70 | CustomOverlay.propTypes = {
71 | provider: MapView.ProviderPropType,
72 | };
73 |
74 | const styles = StyleSheet.create({
75 | container: {
76 | ...StyleSheet.absoluteFillObject,
77 | justifyContent: 'flex-end',
78 | alignItems: 'center',
79 | },
80 | map: {
81 | ...StyleSheet.absoluteFillObject,
82 | },
83 | });
84 |
85 | module.exports = CustomOverlay;
86 |
--------------------------------------------------------------------------------
/example/examples/CustomOverlayXMarksTheSpot.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 | import { View } from 'react-native';
3 | import MapView from 'react-native-maps';
4 |
5 | class XMarksTheSpot extends React.Component {
6 | render() {
7 | return (
8 |
9 |
14 |
17 |
20 |
23 |
24 | );
25 | }
26 | }
27 |
28 | XMarksTheSpot.propTypes = {
29 | coordinates: PropTypes.array,
30 | center: PropTypes.object,
31 | zIndex: PropTypes.number,
32 | };
33 |
34 | export default XMarksTheSpot;
35 |
--------------------------------------------------------------------------------
/example/examples/CustomTiles.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | } from 'react-native';
8 |
9 | import MapView, { MAP_TYPES, PROVIDER_DEFAULT } from 'react-native-maps';
10 |
11 | const { width, height } = Dimensions.get('window');
12 |
13 | const ASPECT_RATIO = width / height;
14 | const LATITUDE = 37.78825;
15 | const LONGITUDE = -122.4324;
16 | const LATITUDE_DELTA = 0.0922;
17 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
18 |
19 | class CustomTiles extends React.Component {
20 | constructor(props, context) {
21 | super(props, context);
22 |
23 | this.state = {
24 | region: {
25 | latitude: LATITUDE,
26 | longitude: LONGITUDE,
27 | latitudeDelta: LATITUDE_DELTA,
28 | longitudeDelta: LONGITUDE_DELTA,
29 | },
30 | };
31 | }
32 |
33 | get mapType() {
34 | // MapKit does not support 'none' as a base map
35 | return this.props.provider === PROVIDER_DEFAULT ?
36 | MAP_TYPES.STANDARD : MAP_TYPES.NONE;
37 | }
38 |
39 | render() {
40 | const { region } = this.state;
41 | return (
42 |
43 |
49 |
53 |
54 |
55 |
56 | Custom Tiles
57 |
58 |
59 |
60 | );
61 | }
62 | }
63 |
64 | CustomTiles.propTypes = {
65 | provider: MapView.ProviderPropType,
66 | };
67 |
68 | const styles = StyleSheet.create({
69 | container: {
70 | position: 'absolute',
71 | top: 0,
72 | left: 0,
73 | right: 0,
74 | bottom: 0,
75 | justifyContent: 'flex-end',
76 | alignItems: 'center',
77 | },
78 | map: {
79 | position: 'absolute',
80 | top: 0,
81 | left: 0,
82 | right: 0,
83 | bottom: 0,
84 | },
85 | bubble: {
86 | flex: 1,
87 | backgroundColor: 'rgba(255,255,255,0.7)',
88 | paddingHorizontal: 18,
89 | paddingVertical: 12,
90 | borderRadius: 20,
91 | },
92 | latlng: {
93 | width: 200,
94 | alignItems: 'stretch',
95 | },
96 | button: {
97 | width: 80,
98 | paddingHorizontal: 12,
99 | alignItems: 'center',
100 | marginHorizontal: 10,
101 | },
102 | buttonContainer: {
103 | flexDirection: 'row',
104 | marginVertical: 20,
105 | backgroundColor: 'transparent',
106 | },
107 | });
108 |
109 | module.exports = CustomTiles;
110 |
--------------------------------------------------------------------------------
/example/examples/DefaultMarkers.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | TouchableOpacity,
8 | } from 'react-native';
9 |
10 | import MapView from 'react-native-maps';
11 |
12 | const { width, height } = Dimensions.get('window');
13 |
14 | const ASPECT_RATIO = width / height;
15 | const LATITUDE = 37.78825;
16 | const LONGITUDE = -122.4324;
17 | const LATITUDE_DELTA = 0.0922;
18 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
19 | let id = 0;
20 |
21 | function randomColor() {
22 | return `#${Math.floor(Math.random() * 16777215).toString(16)}`;
23 | }
24 |
25 | class DefaultMarkers extends React.Component {
26 | constructor(props) {
27 | super(props);
28 |
29 | this.state = {
30 | region: {
31 | latitude: LATITUDE,
32 | longitude: LONGITUDE,
33 | latitudeDelta: LATITUDE_DELTA,
34 | longitudeDelta: LONGITUDE_DELTA,
35 | },
36 | markers: [],
37 | };
38 | }
39 |
40 | onMapPress(e) {
41 | this.setState({
42 | markers: [
43 | ...this.state.markers,
44 | {
45 | coordinate: e.nativeEvent.coordinate,
46 | key: id++,
47 | color: randomColor(),
48 | },
49 | ],
50 | });
51 | }
52 |
53 | render() {
54 | return (
55 |
56 | this.onMapPress(e)}
61 | >
62 | {this.state.markers.map(marker => (
63 |
68 | ))}
69 |
70 |
71 | this.setState({ markers: [] })}
73 | style={styles.bubble}
74 | >
75 | Tap to create a marker of random color
76 |
77 |
78 |
79 | );
80 | }
81 | }
82 |
83 | DefaultMarkers.propTypes = {
84 | provider: MapView.ProviderPropType,
85 | };
86 |
87 | const styles = StyleSheet.create({
88 | container: {
89 | ...StyleSheet.absoluteFillObject,
90 | justifyContent: 'flex-end',
91 | alignItems: 'center',
92 | },
93 | map: {
94 | ...StyleSheet.absoluteFillObject,
95 | },
96 | bubble: {
97 | backgroundColor: 'rgba(255,255,255,0.7)',
98 | paddingHorizontal: 18,
99 | paddingVertical: 12,
100 | borderRadius: 20,
101 | },
102 | latlng: {
103 | width: 200,
104 | alignItems: 'stretch',
105 | },
106 | button: {
107 | width: 80,
108 | paddingHorizontal: 12,
109 | alignItems: 'center',
110 | marginHorizontal: 10,
111 | },
112 | buttonContainer: {
113 | flexDirection: 'row',
114 | marginVertical: 20,
115 | backgroundColor: 'transparent',
116 | },
117 | });
118 |
119 | module.exports = DefaultMarkers;
120 |
--------------------------------------------------------------------------------
/example/examples/DisplayLatLng.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | TouchableOpacity,
8 | } from 'react-native';
9 |
10 | import MapView, { MAP_TYPES } from 'react-native-maps';
11 |
12 | const { width, height } = Dimensions.get('window');
13 |
14 | const ASPECT_RATIO = width / height;
15 | const LATITUDE = 37.78825;
16 | const LONGITUDE = -122.4324;
17 | const LATITUDE_DELTA = 0.0922;
18 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
19 |
20 | class DisplayLatLng extends React.Component {
21 | constructor(props) {
22 | super(props);
23 |
24 | this.state = {
25 | region: {
26 | latitude: LATITUDE,
27 | longitude: LONGITUDE,
28 | latitudeDelta: LATITUDE_DELTA,
29 | longitudeDelta: LONGITUDE_DELTA,
30 | },
31 | };
32 | }
33 |
34 | onRegionChange(region) {
35 | this.setState({ region });
36 | }
37 |
38 | jumpRandom() {
39 | this.setState({ region: this.randomRegion() });
40 | }
41 |
42 | animateRandom() {
43 | this.map.animateToRegion(this.randomRegion());
44 | }
45 |
46 | randomRegion() {
47 | const { region } = this.state;
48 | return {
49 | ...this.state.region,
50 | latitude: region.latitude + ((Math.random() - 0.5) * (region.latitudeDelta / 2)),
51 | longitude: region.longitude + ((Math.random() - 0.5) * (region.longitudeDelta / 2)),
52 | };
53 | }
54 |
55 | render() {
56 | return (
57 |
58 | { this.map = ref; }}
61 | mapType={MAP_TYPES.TERRAIN}
62 | style={styles.map}
63 | initialRegion={this.state.region}
64 | onRegionChange={region => this.onRegionChange(region)}
65 | />
66 |
67 |
68 | {this.state.region.latitude.toPrecision(7)},
69 | {this.state.region.longitude.toPrecision(7)}
70 |
71 |
72 |
73 | this.jumpRandom()}
75 | style={[styles.bubble, styles.button]}
76 | >
77 | Jump
78 |
79 | this.animateRandom()}
81 | style={[styles.bubble, styles.button]}
82 | >
83 | Animate
84 |
85 |
86 |
87 | );
88 | }
89 | }
90 |
91 | DisplayLatLng.propTypes = {
92 | provider: MapView.ProviderPropType,
93 | };
94 |
95 | const styles = StyleSheet.create({
96 | container: {
97 | ...StyleSheet.absoluteFillObject,
98 | justifyContent: 'flex-end',
99 | alignItems: 'center',
100 | },
101 | map: {
102 | ...StyleSheet.absoluteFillObject,
103 | },
104 | bubble: {
105 | backgroundColor: 'rgba(255,255,255,0.7)',
106 | paddingHorizontal: 18,
107 | paddingVertical: 12,
108 | borderRadius: 20,
109 | },
110 | latlng: {
111 | width: 200,
112 | alignItems: 'stretch',
113 | },
114 | button: {
115 | width: 80,
116 | paddingHorizontal: 12,
117 | alignItems: 'center',
118 | marginHorizontal: 10,
119 | },
120 | buttonContainer: {
121 | flexDirection: 'row',
122 | marginVertical: 20,
123 | backgroundColor: 'transparent',
124 | },
125 | });
126 |
127 | module.exports = DisplayLatLng;
128 |
--------------------------------------------------------------------------------
/example/examples/DraggableMarkers.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Dimensions,
6 | } from 'react-native';
7 |
8 | import MapView from 'react-native-maps';
9 | import PriceMarker from './PriceMarker';
10 |
11 | const { width, height } = Dimensions.get('window');
12 |
13 | const ASPECT_RATIO = width / height;
14 | const LATITUDE = 37.78825;
15 | const LONGITUDE = -122.4324;
16 | const LATITUDE_DELTA = 0.0922;
17 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
18 | const SPACE = 0.01;
19 |
20 | function log(eventName, e) {
21 | console.log(eventName, e.nativeEvent);
22 | }
23 |
24 | class MarkerTypes extends React.Component {
25 | constructor(props) {
26 | super(props);
27 |
28 | this.state = {
29 | a: {
30 | latitude: LATITUDE + SPACE,
31 | longitude: LONGITUDE + SPACE,
32 | },
33 | b: {
34 | latitude: LATITUDE - SPACE,
35 | longitude: LONGITUDE - SPACE,
36 | },
37 | };
38 | }
39 |
40 | render() {
41 | return (
42 |
43 |
53 | log('onSelect', e)}
56 | onDrag={(e) => log('onDrag', e)}
57 | onDragStart={(e) => log('onDragStart', e)}
58 | onDragEnd={(e) => log('onDragEnd', e)}
59 | onPress={(e) => log('onPress', e)}
60 | draggable
61 | >
62 |
63 |
64 | log('onSelect', e)}
67 | onDrag={(e) => log('onDrag', e)}
68 | onDragStart={(e) => log('onDragStart', e)}
69 | onDragEnd={(e) => log('onDragEnd', e)}
70 | onPress={(e) => log('onPress', e)}
71 | draggable
72 | />
73 |
74 |
75 | );
76 | }
77 | }
78 |
79 | MarkerTypes.propTypes = {
80 | provider: MapView.ProviderPropType,
81 | };
82 |
83 | const styles = StyleSheet.create({
84 | container: {
85 | ...StyleSheet.absoluteFillObject,
86 | justifyContent: 'flex-end',
87 | alignItems: 'center',
88 | },
89 | map: {
90 | ...StyleSheet.absoluteFillObject,
91 | },
92 | });
93 |
94 | module.exports = MarkerTypes;
95 |
--------------------------------------------------------------------------------
/example/examples/FitToCoordinates.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Dimensions,
6 | TouchableOpacity,
7 | Text,
8 | } from 'react-native';
9 |
10 | import MapView from 'react-native-maps';
11 |
12 | const { width, height } = Dimensions.get('window');
13 |
14 | const ASPECT_RATIO = width / height;
15 | const LATITUDE = 37.78825;
16 | const LONGITUDE = -122.4324;
17 | const LATITUDE_DELTA = 0.0922;
18 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
19 | const SPACE = 0.01;
20 |
21 | function createMarker(modifier = 1) {
22 | return {
23 | latitude: LATITUDE - (SPACE * modifier),
24 | longitude: LONGITUDE - (SPACE * modifier),
25 | };
26 | }
27 |
28 | const MARKERS = [
29 | createMarker(),
30 | createMarker(2),
31 | createMarker(3),
32 | createMarker(4),
33 | ];
34 |
35 | const DEFAULT_PADDING = { top: 40, right: 40, bottom: 40, left: 40 };
36 |
37 | class FitToCoordinates extends React.Component {
38 | fitPadding() {
39 | this.map.fitToCoordinates([MARKERS[2], MARKERS[3]], {
40 | edgePadding: { top: 100, right: 100, bottom: 100, left: 100 },
41 | animated: true,
42 | });
43 | }
44 |
45 | fitBottomTwoMarkers() {
46 | this.map.fitToCoordinates([MARKERS[2], MARKERS[3]], {
47 | edgePadding: DEFAULT_PADDING,
48 | animated: true,
49 | });
50 | }
51 |
52 | fitAllMarkers() {
53 | this.map.fitToCoordinates(MARKERS, {
54 | edgePadding: DEFAULT_PADDING,
55 | animated: true,
56 | });
57 | }
58 |
59 | render() {
60 | return (
61 |
62 | { this.map = ref; }}
64 | style={styles.map}
65 | initialRegion={{
66 | latitude: LATITUDE,
67 | longitude: LONGITUDE,
68 | latitudeDelta: LATITUDE_DELTA,
69 | longitudeDelta: LONGITUDE_DELTA,
70 | }}
71 | >
72 | {MARKERS.map((marker, i) => (
73 |
77 | ))}
78 |
79 |
80 | this.fitPadding()}
82 | style={[styles.bubble, styles.button]}
83 | >
84 | Fit Bottom Two Markers with Padding
85 |
86 | this.fitBottomTwoMarkers()}
88 | style={[styles.bubble, styles.button]}
89 | >
90 | Fit Bottom Two Markers
91 |
92 | this.fitAllMarkers()}
94 | style={[styles.bubble, styles.button]}
95 | >
96 | Fit All Markers
97 |
98 |
99 |
100 | );
101 | }
102 | }
103 |
104 | const styles = StyleSheet.create({
105 | container: {
106 | ...StyleSheet.absoluteFillObject,
107 | justifyContent: 'flex-end',
108 | alignItems: 'center',
109 | },
110 | map: {
111 | ...StyleSheet.absoluteFillObject,
112 | },
113 | bubble: {
114 | backgroundColor: 'rgba(255,255,255,0.7)',
115 | paddingHorizontal: 18,
116 | paddingVertical: 12,
117 | borderRadius: 20,
118 | },
119 | button: {
120 | marginTop: 12,
121 | paddingHorizontal: 12,
122 | alignItems: 'center',
123 | marginHorizontal: 10,
124 | },
125 | buttonContainer: {
126 | flexDirection: 'column',
127 | marginVertical: 20,
128 | backgroundColor: 'transparent',
129 | },
130 | });
131 |
132 | module.exports = FitToCoordinates;
133 |
--------------------------------------------------------------------------------
/example/examples/LiteMapView.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | Dimensions,
5 | ScrollView,
6 | } from 'react-native';
7 |
8 | import MapView from 'react-native-maps';
9 |
10 | const { width, height } = Dimensions.get('window');
11 |
12 | const ASPECT_RATIO = width / height;
13 | const LATITUDE = 37.78825;
14 | const LONGITUDE = -122.4324;
15 | const LATITUDE_DELTA = 0.0922;
16 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
17 |
18 | const SAMPLE_REGION = {
19 | latitude: LATITUDE,
20 | longitude: LONGITUDE,
21 | latitudeDelta: LATITUDE_DELTA,
22 | longitudeDelta: LONGITUDE_DELTA,
23 | };
24 |
25 | class LiteMapView extends React.Component {
26 | render() {
27 | const maps = [];
28 | for (let i = 0; i < 10; i++) {
29 | maps.push(
30 |
36 | );
37 | }
38 | return (
39 |
40 | {maps}
41 |
42 | );
43 | }
44 | }
45 |
46 | const styles = StyleSheet.create({
47 | map: {
48 | height: 200,
49 | marginVertical: 50,
50 | },
51 | });
52 |
53 | module.exports = LiteMapView;
54 |
--------------------------------------------------------------------------------
/example/examples/LoadingMap.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | Dimensions,
6 | StyleSheet,
7 | } from 'react-native';
8 |
9 | import MapView from 'react-native-maps';
10 | import flagImg from './assets/flag-blue.png';
11 |
12 | const { width, height } = Dimensions.get('window');
13 |
14 | const ASPECT_RATIO = width / height;
15 | const LATITUDE = 37.78825;
16 | const LONGITUDE = -122.4324;
17 | const LATITUDE_DELTA = 0.0922;
18 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
19 | const SPACE = 0.01;
20 |
21 | class LoadingMap extends React.Component {
22 | constructor(props) {
23 | super(props);
24 |
25 | this.state = {
26 | region: {
27 | latitude: LATITUDE,
28 | longitude: LONGITUDE,
29 | latitudeDelta: LATITUDE_DELTA,
30 | longitudeDelta: LONGITUDE_DELTA,
31 | },
32 | };
33 | }
34 |
35 | render() {
36 | return (
37 |
38 |
47 |
56 |
64 |
65 |
66 | This is a plain view
67 |
68 |
69 |
70 |
71 |
72 |
73 | Map with Loading
74 |
75 |
76 |
77 | );
78 | }
79 | }
80 |
81 | LoadingMap.propTypes = {
82 | provider: MapView.ProviderPropType,
83 | };
84 |
85 | const styles = StyleSheet.create({
86 | container: {
87 | ...StyleSheet.absoluteFillObject,
88 | justifyContent: 'flex-end',
89 | alignItems: 'center',
90 | },
91 | map: {
92 | ...StyleSheet.absoluteFillObject,
93 | },
94 | bubble: {
95 | backgroundColor: 'rgba(255,255,255,0.7)',
96 | paddingHorizontal: 18,
97 | paddingVertical: 12,
98 | borderRadius: 20,
99 | },
100 | buttonContainer: {
101 | flexDirection: 'row',
102 | marginVertical: 20,
103 | backgroundColor: 'transparent',
104 | },
105 | });
106 |
107 | module.exports = LoadingMap;
108 |
--------------------------------------------------------------------------------
/example/examples/MarkerTypes.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | } from 'react-native';
8 | import MapView from 'react-native-maps';
9 | import flagBlueImg from './assets/flag-blue.png';
10 | import flagPinkImg from './assets/flag-pink.png';
11 |
12 | const { width, height } = Dimensions.get('window');
13 |
14 | const ASPECT_RATIO = width / height;
15 | const LATITUDE = 37.78825;
16 | const LONGITUDE = -122.4324;
17 | const LATITUDE_DELTA = 0.0922;
18 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
19 | const SPACE = 0.01;
20 |
21 | class MarkerTypes extends React.Component {
22 | constructor(props) {
23 | super(props);
24 | this.state = {
25 | marker1: true,
26 | marker2: false,
27 | };
28 | }
29 |
30 | render() {
31 | return (
32 |
33 |
43 | this.setState({ marker1: !this.state.marker1 })}
45 | coordinate={{
46 | latitude: LATITUDE + SPACE,
47 | longitude: LONGITUDE + SPACE,
48 | }}
49 | centerOffset={{ x: -18, y: -60 }}
50 | anchor={{ x: 0.69, y: 1 }}
51 | image={this.state.marker1 ? flagBlueImg : flagPinkImg}
52 | >
53 | X
54 |
55 | this.setState({ marker2: !this.state.marker2 })}
57 | coordinate={{
58 | latitude: LATITUDE - SPACE,
59 | longitude: LONGITUDE - SPACE,
60 | }}
61 | centerOffset={{ x: -42, y: -60 }}
62 | anchor={{ x: 0.84, y: 1 }}
63 | image={this.state.marker2 ? flagBlueImg : flagPinkImg}
64 | />
65 | this.setState({ marker2: !this.state.marker2 })}
67 | coordinate={{
68 | latitude: LATITUDE + SPACE,
69 | longitude: LONGITUDE - SPACE,
70 | }}
71 | centerOffset={{ x: -42, y: -60 }}
72 | anchor={{ x: 0.84, y: 1 }}
73 | opacity={0.6}
74 | image={this.state.marker2 ? flagBlueImg : flagPinkImg}
75 | />
76 |
77 |
78 | );
79 | }
80 | }
81 |
82 | MarkerTypes.propTypes = {
83 | provider: MapView.ProviderPropType,
84 | };
85 |
86 | const styles = StyleSheet.create({
87 | container: {
88 | ...StyleSheet.absoluteFillObject,
89 | justifyContent: 'flex-end',
90 | alignItems: 'center',
91 | },
92 | map: {
93 | ...StyleSheet.absoluteFillObject,
94 | },
95 | marker: {
96 | marginLeft: 46,
97 | marginTop: 33,
98 | fontWeight: 'bold',
99 | },
100 | });
101 |
102 | module.exports = MarkerTypes;
103 |
--------------------------------------------------------------------------------
/example/examples/PriceMarker.js:
--------------------------------------------------------------------------------
1 | import React, { PropTypes } from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | } from 'react-native';
7 |
8 | const propTypes = {
9 | amount: PropTypes.number.isRequired,
10 | fontSize: PropTypes.number,
11 | };
12 |
13 | const defaultProps = {
14 | fontSize: 13,
15 | };
16 |
17 | class PriceMarker extends React.Component {
18 | render() {
19 | const { fontSize, amount } = this.props;
20 | return (
21 |
22 |
23 | $
24 | {amount}
25 |
26 |
27 |
28 |
29 | );
30 | }
31 | }
32 |
33 | PriceMarker.propTypes = propTypes;
34 | PriceMarker.defaultProps = defaultProps;
35 |
36 | const styles = StyleSheet.create({
37 | container: {
38 | flexDirection: 'column',
39 | alignSelf: 'flex-start',
40 | },
41 | bubble: {
42 | flex: 0,
43 | flexDirection: 'row',
44 | alignSelf: 'flex-start',
45 | backgroundColor: '#FF5A5F',
46 | padding: 2,
47 | borderRadius: 3,
48 | borderColor: '#D23F44',
49 | borderWidth: 0.5,
50 | },
51 | dollar: {
52 | color: '#FFFFFF',
53 | fontSize: 10,
54 | },
55 | amount: {
56 | color: '#FFFFFF',
57 | fontSize: 13,
58 | },
59 | arrow: {
60 | backgroundColor: 'transparent',
61 | borderWidth: 4,
62 | borderColor: 'transparent',
63 | borderTopColor: '#FF5A5F',
64 | alignSelf: 'center',
65 | marginTop: -9,
66 | },
67 | arrowBorder: {
68 | backgroundColor: 'transparent',
69 | borderWidth: 4,
70 | borderColor: 'transparent',
71 | borderTopColor: '#D23F44',
72 | alignSelf: 'center',
73 | marginTop: -0.5,
74 | },
75 | });
76 |
77 | module.exports = PriceMarker;
78 |
--------------------------------------------------------------------------------
/example/examples/StaticMap.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | ScrollView,
8 | } from 'react-native';
9 | import MapView from 'react-native-maps';
10 |
11 | const { width, height } = Dimensions.get('window');
12 |
13 | const ASPECT_RATIO = width / height;
14 | const LATITUDE = 37.78825;
15 | const LONGITUDE = -122.4324;
16 | const LATITUDE_DELTA = 0.0922;
17 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
18 |
19 | class StaticMap extends React.Component {
20 | constructor(props) {
21 | super(props);
22 |
23 | this.state = {
24 | region: {
25 | latitude: LATITUDE,
26 | longitude: LONGITUDE,
27 | latitudeDelta: LATITUDE_DELTA,
28 | longitudeDelta: LONGITUDE_DELTA,
29 | },
30 | };
31 | }
32 |
33 | render() {
34 | return (
35 |
36 |
40 | Clicking
41 | and
42 | dragging
43 | the
44 | map
45 | will
46 | cause
47 | the
48 |
57 |
62 |
63 | parent
64 | ScrollView
65 | to
66 | scroll.
67 | When
68 | using
69 | a Google
70 | Map
71 | this only
72 | works
73 | if you
74 | disable:
75 | scroll,
76 | zoom,
77 | pitch,
78 | rotate.
79 | ...
80 | It
81 | would
82 | be
83 | nice
84 | to
85 | have
86 | an
87 | option
88 | that
89 | still
90 | allows
91 | zooming.
92 |
93 |
94 | );
95 | }
96 | }
97 |
98 | StaticMap.propTypes = {
99 | provider: MapView.ProviderPropType,
100 | };
101 |
102 | const styles = StyleSheet.create({
103 | container: {
104 | ...StyleSheet.absoluteFillObject,
105 | justifyContent: 'flex-end',
106 | alignItems: 'center',
107 | },
108 | scrollview: {
109 | alignItems: 'center',
110 | paddingVertical: 40,
111 | },
112 | map: {
113 | width: 250,
114 | height: 250,
115 | },
116 | });
117 |
118 | module.exports = StaticMap;
119 |
--------------------------------------------------------------------------------
/example/examples/ViewsAsMarkers.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | StyleSheet,
4 | View,
5 | Text,
6 | Dimensions,
7 | TouchableOpacity,
8 | } from 'react-native';
9 | import MapView from 'react-native-maps';
10 | import PriceMarker from './PriceMarker';
11 |
12 | const { width, height } = Dimensions.get('window');
13 |
14 | const ASPECT_RATIO = width / height;
15 | const LATITUDE = 37.78825;
16 | const LONGITUDE = -122.4324;
17 | const LATITUDE_DELTA = 0.0922;
18 | const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
19 |
20 | class ViewsAsMarkers extends React.Component {
21 | constructor(props) {
22 | super(props);
23 |
24 | this.state = {
25 | region: {
26 | latitude: LATITUDE,
27 | longitude: LONGITUDE,
28 | latitudeDelta: LATITUDE_DELTA,
29 | longitudeDelta: LONGITUDE_DELTA,
30 | },
31 | coordinate: {
32 | latitude: LATITUDE,
33 | longitude: LONGITUDE,
34 | },
35 | amount: 99,
36 | };
37 | }
38 |
39 | increment() {
40 | this.setState({ amount: this.state.amount + 1 });
41 | }
42 |
43 | decrement() {
44 | this.setState({ amount: this.state.amount - 1 });
45 | }
46 |
47 | render() {
48 | return (
49 |
50 |
55 |
56 |
57 |
58 |
59 |
60 | this.decrement()}
62 | style={[styles.bubble, styles.button]}
63 | >
64 | -
65 |
66 | this.increment()}
68 | style={[styles.bubble, styles.button]}
69 | >
70 | +
71 |
72 |
73 |
74 | );
75 | }
76 | }
77 |
78 | ViewsAsMarkers.propTypes = {
79 | provider: MapView.ProviderPropType,
80 | };
81 |
82 | const styles = StyleSheet.create({
83 | container: {
84 | ...StyleSheet.absoluteFillObject,
85 | justifyContent: 'flex-end',
86 | alignItems: 'center',
87 | },
88 | map: {
89 | ...StyleSheet.absoluteFillObject,
90 | },
91 | bubble: {
92 | backgroundColor: 'rgba(255,255,255,0.7)',
93 | paddingHorizontal: 18,
94 | paddingVertical: 12,
95 | borderRadius: 20,
96 | },
97 | latlng: {
98 | width: 200,
99 | alignItems: 'stretch',
100 | },
101 | button: {
102 | width: 80,
103 | paddingHorizontal: 12,
104 | alignItems: 'center',
105 | marginHorizontal: 10,
106 | },
107 | buttonContainer: {
108 | flexDirection: 'row',
109 | marginVertical: 20,
110 | backgroundColor: 'transparent',
111 | },
112 | });
113 |
114 | module.exports = ViewsAsMarkers;
115 |
--------------------------------------------------------------------------------
/example/examples/ZIndexMarkers.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Dimensions,
4 | StyleSheet,
5 | Text,
6 | View,
7 | } from 'react-native';
8 |
9 | import MapView from 'react-native-maps';
10 |
11 | const { width, height } = Dimensions.get('window');
12 |
13 | const ASPECT_RATIO = width / height;
14 | const LATITUDE = 37.733858;
15 | const LONGITUDE = -122.446549;
16 | const MARKERS_LATITUDE_DELTA = 0.03;
17 | const MARKERS_LONGITUDE_DELTA = MARKERS_LATITUDE_DELTA * ASPECT_RATIO;
18 | const MAP_LATITUDE_DELTA = 0.3;
19 | const MAP_LONGITUDE_DELTA = MAP_LATITUDE_DELTA * ASPECT_RATIO;
20 | const NUM_MARKERS = 100;
21 | const PERCENT_SPECIAL_MARKERS = 0.1;
22 |
23 | class ZIndexMarkers extends React.Component {
24 | constructor(props) {
25 | super(props);
26 |
27 | const markerInfo = [];
28 | for (let i = 1; i < NUM_MARKERS; i++) {
29 | markerInfo.push({
30 | latitude: (((Math.random() * 2) - 1) * MARKERS_LATITUDE_DELTA) + LATITUDE,
31 | longitude: (((Math.random() * 2) - 1) * MARKERS_LONGITUDE_DELTA) + LONGITUDE,
32 | isSpecial: Math.random() < PERCENT_SPECIAL_MARKERS,
33 | id: i,
34 | });
35 | }
36 |
37 | this.state = {
38 | markerInfo,
39 | };
40 | }
41 |
42 | render() {
43 | const markers = this.state.markerInfo.map((markerInfo) =>
44 |
50 | );
51 |
52 | return (
53 |
54 | { this.map = ref; }}
57 | style={styles.map}
58 | initialRegion={{
59 | latitude: LATITUDE,
60 | longitude: LONGITUDE,
61 | latitudeDelta: MAP_LATITUDE_DELTA,
62 | longitudeDelta: MAP_LONGITUDE_DELTA,
63 | }}
64 | >
65 | {markers}
66 |
67 |
68 | The yellow markers have a higher zIndex and appear above other markers.
69 |
70 |
71 | );
72 | }
73 | }
74 |
75 | ZIndexMarkers.propTypes = {
76 | provider: MapView.ProviderPropType,
77 | };
78 |
79 | const styles = StyleSheet.create({
80 | container: {
81 | ...StyleSheet.absoluteFillObject,
82 | justifyContent: 'flex-end',
83 | alignItems: 'center',
84 | },
85 | map: {
86 | ...StyleSheet.absoluteFillObject,
87 | },
88 | textContainer: {
89 | backgroundColor: 'white',
90 | borderRadius: 4,
91 | marginHorizontal: 40,
92 | marginVertical: 20,
93 | padding: 10,
94 | },
95 | specialMarker: {
96 | zIndex: 1,
97 | },
98 | });
99 |
100 | module.exports = ZIndexMarkers;
101 |
--------------------------------------------------------------------------------
/example/examples/assets/flag-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/example/examples/assets/flag-blue.png
--------------------------------------------------------------------------------
/example/examples/assets/flag-pink.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/commaai/react-native-maps/c4ed1279244ac3faa6b3944339724c48f96ce464/example/examples/assets/flag-pink.png
--------------------------------------------------------------------------------
/example/index.android.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { AppRegistry } from 'react-native';
3 | import App from './App';
4 |
5 | class AirMapsExplorer extends React.Component {
6 | render() {
7 | return ;
8 | }
9 | }
10 |
11 | AppRegistry.registerComponent('AirMapsExplorer', () => AirMapsExplorer);
12 |
--------------------------------------------------------------------------------
/example/index.ios.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { AppRegistry } from 'react-native';
3 | import App from './App';
4 |
5 | class AirMapsExplorer extends React.Component {
6 | render() {
7 | return ;
8 | }
9 | }
10 |
11 | AppRegistry.registerComponent('AirMapsExplorer', () => AirMapsExplorer);
12 |
--------------------------------------------------------------------------------
/example/ios/AirMapsExplorer/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (nonatomic, strong) UIWindow *window;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/example/ios/AirMapsExplorer/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AppDelegate.h"
11 |
12 | #import
13 |
14 | #import
15 |
16 | @implementation AppDelegate
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
19 | {
20 | NSURL *jsCodeLocation;
21 |
22 | [GMSServices provideAPIKey:@"AIzaSyAeHIC4IG7XKT2Ls5Ti_YZV-6DHQk6dVHE"];
23 |
24 | /**
25 | * Loading JavaScript code - uncomment the one you want.
26 | *
27 | * OPTION 1
28 | * Load from development server. Start the server from the repository root:
29 | *
30 | * $ npm start
31 | *
32 | * To run on device, change `localhost` to the IP address of your computer
33 | * (you can get this by typing `ifconfig` into the terminal and selecting the
34 | * `inet` value under `en0:`) and make sure your computer and iOS device are
35 | * on the same Wi-Fi network.
36 | */
37 |
38 | jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
39 |
40 | /**
41 | * OPTION 2
42 | * Load from pre-bundled file on disk. The static bundle is automatically
43 | * generated by "Bundle React Native code and images" build step.
44 | */
45 |
46 | // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
47 |
48 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
49 | moduleName:@"AirMapsExplorer"
50 | initialProperties:nil
51 | launchOptions:launchOptions];
52 |
53 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
54 | UIViewController *rootViewController = [UIViewController new];
55 | rootViewController.view = rootView;
56 | self.window.rootViewController = rootViewController;
57 | [self.window makeKeyAndVisible];
58 | return YES;
59 | }
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/example/ios/AirMapsExplorer/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/example/ios/AirMapsExplorer/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSAppTransportSecurity
26 |
27 | NSAllowsArbitraryLoads
28 |
29 |
30 | NSLocationWhenInUseUsageDescription
31 |
32 | UILaunchStoryboardName
33 | LaunchScreen
34 | UIRequiredDeviceCapabilities
35 |
36 | armv7
37 |
38 | UISupportedInterfaceOrientations
39 |
40 | UIInterfaceOrientationPortrait
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example/ios/AirMapsExplorer/main.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import "AppDelegate.h"
13 |
14 | int main(int argc, char * argv[]) {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/example/ios/AirMapsExplorerTests/AirMapsExplorerTests.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 | #import
12 |
13 | #import
14 | #import
15 |
16 | #define TIMEOUT_SECONDS 240
17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
18 |
19 | @interface AirMapsExplorerTests : XCTestCase
20 |
21 | @end
22 |
23 | @implementation AirMapsExplorerTests
24 |
25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
26 | {
27 | if (test(view)) {
28 | return YES;
29 | }
30 | for (UIView *subview in [view subviews]) {
31 | if ([self findSubviewInView:subview matching:test]) {
32 | return YES;
33 | }
34 | }
35 | return NO;
36 | }
37 |
38 | - (void)testRendersWelcomeScreen
39 | {
40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
42 | BOOL foundElement = NO;
43 |
44 | __block NSString *redboxError = nil;
45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
46 | if (level >= RCTLogLevelError) {
47 | redboxError = message;
48 | }
49 | });
50 |
51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
54 |
55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
57 | return YES;
58 | }
59 | return NO;
60 | }];
61 | }
62 |
63 | RCTSetLogFunction(RCTDefaultLogFunction);
64 |
65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
67 | }
68 |
69 |
70 | @end
71 |
--------------------------------------------------------------------------------
/example/ios/AirMapsExplorerTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/ios/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | gem 'cocoapods', '~>1.1.1'
3 |
--------------------------------------------------------------------------------
/example/ios/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (2.3.3)
5 | activesupport (4.2.7.1)
6 | i18n (~> 0.7)
7 | json (~> 1.7, >= 1.7.7)
8 | minitest (~> 5.1)
9 | thread_safe (~> 0.3, >= 0.3.4)
10 | tzinfo (~> 1.1)
11 | claide (1.0.1)
12 | cocoapods (1.1.1)
13 | activesupport (>= 4.0.2, < 5)
14 | claide (>= 1.0.1, < 2.0)
15 | cocoapods-core (= 1.1.1)
16 | cocoapods-deintegrate (>= 1.0.1, < 2.0)
17 | cocoapods-downloader (>= 1.1.2, < 2.0)
18 | cocoapods-plugins (>= 1.0.0, < 2.0)
19 | cocoapods-search (>= 1.0.0, < 2.0)
20 | cocoapods-stats (>= 1.0.0, < 2.0)
21 | cocoapods-trunk (>= 1.1.1, < 2.0)
22 | cocoapods-try (>= 1.1.0, < 2.0)
23 | colored (~> 1.2)
24 | escape (~> 0.0.4)
25 | fourflusher (~> 2.0.1)
26 | gh_inspector (~> 1.0)
27 | molinillo (~> 0.5.1)
28 | nap (~> 1.0)
29 | xcodeproj (>= 1.3.3, < 2.0)
30 | cocoapods-core (1.1.1)
31 | activesupport (>= 4.0.2, < 5)
32 | fuzzy_match (~> 2.0.4)
33 | nap (~> 1.0)
34 | cocoapods-deintegrate (1.0.1)
35 | cocoapods-downloader (1.1.2)
36 | cocoapods-plugins (1.0.0)
37 | nap
38 | cocoapods-search (1.0.0)
39 | cocoapods-stats (1.0.0)
40 | cocoapods-trunk (1.1.1)
41 | nap (>= 0.8, < 2.0)
42 | netrc (= 0.7.8)
43 | cocoapods-try (1.1.0)
44 | colored (1.2)
45 | escape (0.0.4)
46 | fourflusher (2.0.1)
47 | fuzzy_match (2.0.4)
48 | gh_inspector (1.0.2)
49 | i18n (0.7.0)
50 | json (1.8.3)
51 | minitest (5.9.1)
52 | molinillo (0.5.3)
53 | nanaimo (0.2.2)
54 | nap (1.1.0)
55 | netrc (0.7.8)
56 | thread_safe (0.3.5)
57 | tzinfo (1.2.2)
58 | thread_safe (~> 0.1)
59 | xcodeproj (1.4.1)
60 | CFPropertyList (~> 2.3.3)
61 | activesupport (>= 3)
62 | claide (>= 1.0.1, < 2.0)
63 | colored (~> 1.2)
64 | nanaimo (~> 0.2.0)
65 |
66 | PLATFORMS
67 | ruby
68 |
69 | DEPENDENCIES
70 | cocoapods (~> 1.1.1)
71 |
72 | BUNDLED WITH
73 | 1.10.6
74 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # You Podfile should look similar to this file. React Native currently does not support use_frameworks!
2 | source 'https://github.com/CocoaPods/Specs.git'
3 |
4 | platform :ios, '8.0'
5 |
6 | # Change 'AirMapsExplorer' to match the target in your Xcode project.
7 | target 'AirMapsExplorer' do
8 | pod 'React', path: '../node_modules/react-native', :subspecs => [
9 | 'Core',
10 | 'RCTActionSheet',
11 | 'RCTAnimation',
12 | 'RCTGeolocation',
13 | 'RCTImage',
14 | 'RCTLinkingIOS',
15 | 'RCTNetwork',
16 | 'RCTSettings',
17 | 'RCTText',
18 | 'RCTVibration',
19 | 'RCTWebSocket'
20 | ]
21 |
22 | pod 'GoogleMaps' # <~~ remove this line if you do not want to support GoogleMaps on iOS
23 |
24 | # when not using frameworks we can do this instead of including the source files in our project (1/4):
25 | # pod 'react-native-maps', path: '../../'
26 | # pod 'react-native-google-maps', path: '../../' # <~~ if you need GoogleMaps support on iOS
27 | end
28 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - GoogleMaps (2.1.1):
3 | - GoogleMaps/Maps (= 2.1.1)
4 | - GoogleMaps/Base (2.1.1)
5 | - GoogleMaps/Maps (2.1.1):
6 | - GoogleMaps/Base
7 | - React/Core (0.40.0):
8 | - React/cxxreact
9 | - React/yoga
10 | - React/cxxreact (0.40.0):
11 | - React/jschelpers
12 | - React/jschelpers (0.40.0)
13 | - React/RCTActionSheet (0.40.0):
14 | - React/Core
15 | - React/RCTAnimation (0.40.0):
16 | - React/Core
17 | - React/RCTGeolocation (0.40.0):
18 | - React/Core
19 | - React/RCTImage (0.40.0):
20 | - React/Core
21 | - React/RCTNetwork
22 | - React/RCTLinkingIOS (0.40.0):
23 | - React/Core
24 | - React/RCTNetwork (0.40.0):
25 | - React/Core
26 | - React/RCTSettings (0.40.0):
27 | - React/Core
28 | - React/RCTText (0.40.0):
29 | - React/Core
30 | - React/RCTVibration (0.40.0):
31 | - React/Core
32 | - React/RCTWebSocket (0.40.0):
33 | - React/Core
34 | - React/yoga (0.40.0)
35 |
36 | DEPENDENCIES:
37 | - GoogleMaps
38 | - React/Core (from `../node_modules/react-native`)
39 | - React/RCTActionSheet (from `../node_modules/react-native`)
40 | - React/RCTAnimation (from `../node_modules/react-native`)
41 | - React/RCTGeolocation (from `../node_modules/react-native`)
42 | - React/RCTImage (from `../node_modules/react-native`)
43 | - React/RCTLinkingIOS (from `../node_modules/react-native`)
44 | - React/RCTNetwork (from `../node_modules/react-native`)
45 | - React/RCTSettings (from `../node_modules/react-native`)
46 | - React/RCTText (from `../node_modules/react-native`)
47 | - React/RCTVibration (from `../node_modules/react-native`)
48 | - React/RCTWebSocket (from `../node_modules/react-native`)
49 |
50 | EXTERNAL SOURCES:
51 | React:
52 | :path: "../node_modules/react-native"
53 |
54 | SPEC CHECKSUMS:
55 | GoogleMaps: a5b5bbe47734e2443bde781a6aa64e69fdb6d785
56 | React: 6dfb2f72edb1d74a800127ae157af038646673ce
57 |
58 | PODFILE CHECKSUM: ffbc20bd08f662256d501d07a70e77862684f702
59 |
60 | COCOAPODS: 1.1.1
61 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "AirMapsExplorer",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "react-native start",
7 | "watch": "node ./scripts/watch-and-copy-src.js",
8 | "packager": "sh ./node_modules/react-native/packager/packager.sh --root ./node_modules/react-native-maps",
9 | "dev": "concurrently 'npm run watch' 'npm run packager'"
10 | },
11 | "dependencies": {
12 | "react": "~15.4.1",
13 | "react-native": "^0.41.2",
14 | "react-native-maps": "file:../"
15 | },
16 | "devDependencies": {
17 | "concurrently": "^2.2.0",
18 | "fs-extra": "^0.30.0",
19 | "minimatch": "^3.0.2",
20 | "node-watch": "^0.4.0",
21 | "rimraf": "^2.5.4"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/scripts/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | // Scripts can import things in devDependencies
4 | "import/no-extraneous-dependencies": [2, {"devDependencies": true}]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/scripts/watch-and-copy-src.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const fs = require('fs-extra');
3 | const watch = require('node-watch');
4 | const rimraf = require('rimraf');
5 | const minimatch = require('minimatch');
6 |
7 | function copyAndWatch(source, destination, fileGlob) {
8 | console.log(`Cleaning "${destination}"`);
9 | rimraf(destination, () => {
10 | console.log(`Copying "${source}" to "${destination}"`);
11 | fs.copy(source, destination, (err) => {
12 | if (err) console.error(err);
13 | });
14 |
15 | console.log(`Watching "${source}"`);
16 | watch(source, (filename) => {
17 | const localPath = filename.split(source).pop();
18 | if (matchesFile(localPath, fileGlob)) {
19 | const destinationPath = `${destination}${localPath}`;
20 | console.log(`Copying "${filename}" to "${destinationPath}"`);
21 | fs.copy(filename, destinationPath, (err) => {
22 | if (err) console.error(err);
23 | });
24 | }
25 | });
26 | });
27 | }
28 |
29 | function matchesFile(filename, fileGlob) {
30 | if (fileGlob == null) return true;
31 | return minimatch(path.basename(filename), fileGlob);
32 | }
33 |
34 | // JavaScript
35 | copyAndWatch(
36 | '../components',
37 | 'node_modules/react-native-maps/components'
38 | );
39 |
40 | // Android
41 | copyAndWatch(
42 | '../android',
43 | 'node_modules/react-native-maps/android'
44 | );
45 |
46 | // iOS
47 | copyAndWatch(
48 | '../ios',
49 | 'node_modules/react-native-maps/ios',
50 | '{*.m,*.h,*.swift}'
51 | );
52 |
--------------------------------------------------------------------------------
/example/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | rm -rf node_modules/react-native-maps
3 | npm install
4 | cd android
5 | ./gradlew app:build
6 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | import MapView from './components/MapView';
2 |
3 | module.exports = MapView;
4 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGMSMarker.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGMSMarker.h
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/5/16.
6 | //
7 |
8 | #import
9 | #import
10 |
11 | @class AIRGoogleMapMarker;
12 |
13 | @interface AIRGMSMarker : GMSMarker
14 | @property (nonatomic, strong) NSString *identifier;
15 | @property (nonatomic, weak) AIRGoogleMapMarker *fakeMarker;
16 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
17 | @end
18 |
19 |
20 | @protocol AIRGMSMarkerDelegate
21 | @required
22 | -(void)didTapMarker;
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGMSMarker.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGMSMarker.m
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/5/16.
6 | //
7 |
8 | #import "AIRGMSMarker.h"
9 |
10 | @implementation AIRGMSMarker
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMap.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMap.h
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/1/16.
6 | //
7 |
8 | #import
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import "AIRGMSMarker.h"
14 |
15 | @interface AIRGoogleMap : GMSMapView
16 |
17 | // TODO: don't use MK region?
18 | @property (nonatomic, assign) MKCoordinateRegion initialRegion;
19 | @property (nonatomic, assign) MKCoordinateRegion region;
20 | @property (nonatomic, assign) NSString *customMapStyleString;
21 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
22 | @property (nonatomic, copy) RCTBubblingEventBlock onLongPress;
23 | @property (nonatomic, copy) RCTBubblingEventBlock onMarkerPress;
24 | @property (nonatomic, copy) RCTBubblingEventBlock onChange;
25 | @property (nonatomic, copy) RCTDirectEventBlock onRegionChange;
26 | @property (nonatomic, copy) RCTDirectEventBlock onRegionChangeComplete;
27 | @property (nonatomic, strong) NSMutableArray *markers;
28 | @property (nonatomic, strong) NSMutableArray *polygons;
29 | @property (nonatomic, strong) NSMutableArray *polylines;
30 | @property (nonatomic, strong) NSMutableArray *circles;
31 | @property (nonatomic, strong) NSMutableArray *tiles;
32 |
33 | @property (nonatomic, assign) BOOL showsBuildings;
34 | @property (nonatomic, assign) BOOL showsTraffic;
35 | @property (nonatomic, assign) BOOL showsCompass;
36 | @property (nonatomic, assign) BOOL scrollEnabled;
37 | @property (nonatomic, assign) BOOL zoomEnabled;
38 | @property (nonatomic, assign) BOOL rotateEnabled;
39 | @property (nonatomic, assign) BOOL pitchEnabled;
40 | @property (nonatomic, assign) BOOL showsUserLocation;
41 |
42 | - (BOOL)didTapMarker:(GMSMarker *)marker;
43 | - (void)didTapAtCoordinate:(CLLocationCoordinate2D)coordinate;
44 | - (void)didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate;
45 | - (void)didChangeCameraPosition:(GMSCameraPosition *)position;
46 | - (void)idleAtCameraPosition:(GMSCameraPosition *)position;
47 |
48 | + (MKCoordinateRegion)makeGMSCameraPositionFromMap:(GMSMapView *)map andGMSCameraPosition:(GMSCameraPosition *)position;
49 | + (GMSCameraPosition*)makeGMSCameraPositionFromMap:(GMSMapView *)map andMKCoordinateRegion:(MKCoordinateRegion)region;
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCallout.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapCallout.h
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/6/16.
6 | //
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AIRGoogleMapCallout : UIView
13 | @property (nonatomic, assign) BOOL tooltip;
14 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCallout.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapCallout.m
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/6/16.
6 | //
7 | //
8 |
9 | #import "AIRGoogleMapCallout.h"
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation AIRGoogleMapCallout
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapCalloutManager.h
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/6/16.
6 | //
7 | //
8 | #import
9 |
10 | @interface AIRGoogleMapCalloutManager : RCTViewManager
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCalloutManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapCalloutManager.m
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/6/16.
6 | //
7 | //
8 |
9 | #import "AIRGoogleMapCalloutManager.h"
10 | #import "AIRGoogleMapCallout.h"
11 | #import
12 |
13 | @implementation AIRGoogleMapCalloutManager
14 | RCT_EXPORT_MODULE()
15 |
16 | - (UIView *)view
17 | {
18 | AIRGoogleMapCallout *callout = [AIRGoogleMapCallout new];
19 | return callout;
20 | }
21 |
22 | RCT_EXPORT_VIEW_PROPERTY(tooltip, BOOL)
23 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCircle.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapsCircle.h
3 | //
4 | // Created by Nick Italiano on 10/24/16.
5 | //
6 |
7 | #import
8 | #import "AIRMapCoordinate.h"
9 |
10 | @interface AIRGoogleMapCircle : UIView
11 |
12 | @property (nonatomic, strong) GMSCircle *circle;
13 | @property (nonatomic, assign) double radius;
14 | @property (nonatomic, assign) CLLocationCoordinate2D centerCoordinate;
15 | @property (nonatomic, assign) UIColor *strokeColor;
16 | @property (nonatomic, assign) double strokeWidth;
17 | @property (nonatomic, assign) UIColor *fillColor;
18 | @property (nonatomic, assign) int zIndex;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCircle.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapsCircle.m
3 | //
4 | // Created by Nick Italiano on 10/24/16.
5 | //
6 | #import
7 | #import "AIRGoogleMapCircle.h"
8 | #import
9 | #import
10 |
11 | @implementation AIRGoogleMapCircle
12 |
13 | - (instancetype)init
14 | {
15 | if (self = [super init]) {
16 | _circle = [[GMSCircle alloc] init];
17 | }
18 | return self;
19 | }
20 |
21 | - (void)setRadius:(double)radius
22 | {
23 | _radius = radius;
24 | _circle.radius = radius;
25 | }
26 |
27 | - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
28 | {
29 | _centerCoordinate = centerCoordinate;
30 | _circle.position = centerCoordinate;
31 | }
32 |
33 | -(void)setStrokeColor:(UIColor *)strokeColor
34 | {
35 | _strokeColor = strokeColor;
36 | _circle.strokeColor = strokeColor;
37 | }
38 |
39 | -(void)setStrokeWidth:(double)strokeWidth
40 | {
41 | _strokeWidth = strokeWidth;
42 | _circle.strokeWidth = strokeWidth;
43 | }
44 |
45 | -(void)setFillColor:(UIColor *)fillColor
46 | {
47 | _fillColor = fillColor;
48 | _circle.fillColor = fillColor;
49 | }
50 |
51 | -(void)setZIndex:(int)zIndex
52 | {
53 | _zIndex = zIndex;
54 | _circle.zIndex = zIndex;
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCircleManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapCircleManager.h
3 | //
4 | // Created by Nick Italiano on 10/24/16.
5 | //
6 |
7 | #import
8 |
9 | @interface AIRGoogleMapCircleManager : RCTViewManager
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapCircleManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapCircleManager.m
3 | //
4 | // Created by Nick Italiano on 10/24/16.
5 | //
6 |
7 | #import "AIRGoogleMapCircleManager.h"
8 | #import "AIRGoogleMapCircle.h"
9 | #import
10 | #import
11 |
12 | @interface AIRGoogleMapCircleManager()
13 |
14 | @end
15 |
16 | @implementation AIRGoogleMapCircleManager
17 |
18 | RCT_EXPORT_MODULE()
19 |
20 | - (UIView *)view
21 | {
22 | AIRGoogleMapCircle *circle = [AIRGoogleMapCircle new];
23 | return circle;
24 | }
25 |
26 | RCT_EXPORT_VIEW_PROPERTY(radius, double)
27 | RCT_REMAP_VIEW_PROPERTY(center, centerCoordinate, CLLocationCoordinate2D)
28 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
29 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, double)
30 | RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
31 | RCT_EXPORT_VIEW_PROPERTY(zIndex, int)
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapManager.h
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/1/16.
6 | //
7 |
8 | #import
9 |
10 | @interface AIRGoogleMapManager : RCTViewManager
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapMarker.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapMarker.h
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/2/16.
6 | //
7 |
8 | #import
9 | #import
10 | #import "AIRGMSMarker.h"
11 | #import "AIRGoogleMap.h"
12 | #import "AIRGoogleMapCallout.h"
13 |
14 | @interface AIRGoogleMapMarker : UIView
15 |
16 | @property (nonatomic, weak) RCTBridge *bridge;
17 | @property (nonatomic, strong) AIRGoogleMapCallout *calloutView;
18 | @property (nonatomic, strong) NSString *identifier;
19 | @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
20 | @property (nonatomic, strong) AIRGMSMarker* realMarker;
21 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
22 | @property (nonatomic, copy) RCTDirectEventBlock onDragStart;
23 | @property (nonatomic, copy) RCTDirectEventBlock onDrag;
24 | @property (nonatomic, copy) RCTDirectEventBlock onDragEnd;
25 | @property (nonatomic, copy) NSString *imageSrc;
26 | @property (nonatomic, copy) NSString *title;
27 | @property (nonatomic, copy) NSString *subtitle;
28 | @property (nonatomic, strong) UIColor *pinColor;
29 | @property (nonatomic, assign) CGPoint anchor;
30 | @property (nonatomic, assign) NSInteger zIndex;
31 | @property (nonatomic, assign) double opacity;
32 | @property (nonatomic, assign) BOOL draggable;
33 |
34 | - (void)showCalloutView;
35 | - (void)hideCalloutView;
36 | - (UIView *)markerInfoContents;
37 | - (UIView *)markerInfoWindow;
38 | - (void)didTapInfoWindowOfMarker:(AIRGMSMarker *)marker;
39 | - (void)didBeginDraggingMarker:(AIRGMSMarker *)marker;
40 | - (void)didEndDraggingMarker:(AIRGMSMarker *)marker;
41 | - (void)didDragMarker:(AIRGMSMarker *)marker;
42 | @end
43 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapMarkerManager.h
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/2/16.
6 | //
7 |
8 | #import
9 |
10 | @interface AIRGoogleMapMarkerManager : RCTViewManager
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapMarkerManager.m
3 | // AirMaps
4 | //
5 | // Created by Gil Birman on 9/2/16.
6 | //
7 |
8 | #import "AIRGoogleMapMarkerManager.h"
9 | #import "AIRGoogleMapMarker.h"
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation AIRGoogleMapMarkerManager
15 |
16 | RCT_EXPORT_MODULE()
17 |
18 | - (UIView *)view
19 | {
20 | AIRGoogleMapMarker *marker = [AIRGoogleMapMarker new];
21 | // UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_handleTap:)];
22 | // // setting this to NO allows the parent MapView to continue receiving marker selection events
23 | // tapGestureRecognizer.cancelsTouchesInView = NO;
24 | // [marker addGestureRecognizer:tapGestureRecognizer];
25 | marker.bridge = self.bridge;
26 | return marker;
27 | }
28 |
29 | RCT_EXPORT_VIEW_PROPERTY(identifier, NSString)
30 | RCT_EXPORT_VIEW_PROPERTY(coordinate, CLLocationCoordinate2D)
31 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
32 | RCT_REMAP_VIEW_PROPERTY(image, imageSrc, NSString)
33 | RCT_EXPORT_VIEW_PROPERTY(title, NSString)
34 | RCT_REMAP_VIEW_PROPERTY(description, subtitle, NSString)
35 | RCT_EXPORT_VIEW_PROPERTY(pinColor, UIColor)
36 | RCT_EXPORT_VIEW_PROPERTY(anchor, CGPoint)
37 | RCT_EXPORT_VIEW_PROPERTY(zIndex, NSInteger)
38 | RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
39 | RCT_EXPORT_VIEW_PROPERTY(opacity, double)
40 | RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTDirectEventBlock)
41 | RCT_EXPORT_VIEW_PROPERTY(onDrag, RCTDirectEventBlock)
42 | RCT_EXPORT_VIEW_PROPERTY(onDragEnd, RCTDirectEventBlock)
43 |
44 | RCT_EXPORT_METHOD(showCallout:(nonnull NSNumber *)reactTag)
45 | {
46 | [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) {
47 | id view = viewRegistry[reactTag];
48 | if (![view isKindOfClass:[AIRGoogleMapMarker class]]) {
49 | RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
50 | } else {
51 | [(AIRGoogleMapMarker *) view showCalloutView];
52 | }
53 | }];
54 | }
55 |
56 | RCT_EXPORT_METHOD(hideCallout:(nonnull NSNumber *)reactTag)
57 | {
58 | [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) {
59 | id view = viewRegistry[reactTag];
60 | if (![view isKindOfClass:[AIRGoogleMapMarker class]]) {
61 | RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
62 | } else {
63 | [(AIRGoogleMapMarker *) view hideCalloutView];
64 | }
65 | }];
66 | }
67 | @end
68 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolygon.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolygon.h
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 |
7 | #import
8 | #import "AIRMapCoordinate.h"
9 |
10 | @interface AIRGoogleMapPolygon : UIView
11 |
12 | @property (nonatomic, strong) GMSPolygon *polygon;
13 | @property (nonatomic, strong) NSArray *coordinates;
14 | @property (nonatomic, strong) NSArray *> *holes;
15 |
16 | @property (nonatomic, assign) UIColor *fillColor;
17 | @property (nonatomic, assign) double strokeWidth;
18 | @property (nonatomic, assign) UIColor *strokeColor;
19 | @property (nonatomic, assign) BOOL geodesic;
20 | @property (nonatomic, assign) int zIndex;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolygon.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolygon.m
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 |
7 | #import "AIRGoogleMapPolygon.h"
8 | #import
9 |
10 | @implementation AIRGoogleMapPolygon
11 |
12 | - (instancetype)init
13 | {
14 | if (self = [super init]) {
15 | _polygon = [[GMSPolygon alloc] init];
16 | }
17 |
18 | return self;
19 | }
20 |
21 | - (void)setCoordinates:(NSArray *)coordinates
22 | {
23 | _coordinates = coordinates;
24 |
25 | GMSMutablePath *path = [GMSMutablePath path];
26 | for(int i = 0; i < coordinates.count; i++)
27 | {
28 | [path addCoordinate:coordinates[i].coordinate];
29 | }
30 |
31 | _polygon.path = path;
32 | }
33 |
34 | - (void)setHoles:(NSArray *> *)holes
35 | {
36 | _holes = holes;
37 |
38 | if (holes.count)
39 | {
40 | NSMutableArray *interiorPolygons = [NSMutableArray array];
41 | for(int h = 0; h < holes.count; h++)
42 | {
43 | GMSMutablePath *path = [GMSMutablePath path];
44 | for(int i = 0; i < holes[h].count; i++)
45 | {
46 | [path addCoordinate:holes[h][i].coordinate];
47 | }
48 | [interiorPolygons addObject:path];
49 | }
50 |
51 | _polygon.holes = interiorPolygons;
52 | }
53 | }
54 |
55 | -(void)setFillColor:(UIColor *)fillColor
56 | {
57 | _fillColor = fillColor;
58 | _polygon.fillColor = fillColor;
59 | }
60 |
61 | -(void)setStrokeWidth:(double)strokeWidth
62 | {
63 | _strokeWidth = strokeWidth;
64 | _polygon.strokeWidth = strokeWidth;
65 | }
66 |
67 | -(void)setStrokeColor:(UIColor *) strokeColor
68 | {
69 | _strokeColor = strokeColor;
70 | _polygon.strokeColor = strokeColor;
71 | }
72 |
73 | -(void)setGeodesic:(BOOL)geodesic
74 | {
75 | _geodesic = geodesic;
76 | _polygon.geodesic = geodesic;
77 | }
78 |
79 | -(void)setZIndex:(int)zIndex
80 | {
81 | _zIndex = zIndex;
82 | _polygon.zIndex = zIndex;
83 | }
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolylgoneManager.h
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 |
7 | #import
8 |
9 | @interface AIRGoogleMapPolygonManager : RCTViewManager
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolylgoneManager.m
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 | #import "AIRGoogleMapPolygonManager.h"
7 |
8 | #import
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import "RCTConvert+MoreMapKit.h"
15 | #import "AIRGoogleMapPolygon.h"
16 |
17 | @interface AIRGoogleMapPolygonManager()
18 |
19 | @end
20 |
21 | @implementation AIRGoogleMapPolygonManager
22 |
23 | RCT_EXPORT_MODULE()
24 |
25 | - (UIView *)view
26 | {
27 | AIRGoogleMapPolygon *polygon = [AIRGoogleMapPolygon new];
28 | return polygon;
29 | }
30 |
31 | RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRMapCoordinateArray)
32 | RCT_EXPORT_VIEW_PROPERTY(holes, AIRMapCoordinateArrayArray)
33 | RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
34 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, double)
35 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
36 | RCT_EXPORT_VIEW_PROPERTY(geodesic, BOOL)
37 | RCT_EXPORT_VIEW_PROPERTY(zIndex, int)
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolyline.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolyline.h
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 | #import
7 | #import
8 | #import "AIRMapCoordinate.h"
9 | #import "AIRGoogleMapMarker.h"
10 |
11 | @interface AIRGoogleMapPolyline : UIView
12 |
13 | @property (nonatomic, strong) GMSPolyline* polyline;
14 | @property (nonatomic, strong) NSArray *coordinates;
15 | @property (nonatomic, strong) UIColor *strokeColor;
16 | @property (nonatomic, assign) double strokeWidth;
17 | @property (nonatomic, assign) UIColor *fillColor;
18 | @property (nonatomic, assign) BOOL geodesic;
19 | @property (nonatomic, assign) NSString *title;
20 | @property (nonatomic, assign) int zIndex;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolyline.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolyline.m
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 | #import
7 | #import "AIRGoogleMapPolyline.h"
8 | #import "AIRMapCoordinate.h"
9 | #import "AIRGoogleMapMarker.h"
10 | #import "AIRGoogleMapMarkerManager.h"
11 | #import
12 | #import
13 |
14 | @implementation AIRGoogleMapPolyline
15 |
16 | - (instancetype)init
17 | {
18 | if (self = [super init]) {
19 | _polyline = [[GMSPolyline alloc] init];
20 | }
21 | return self;
22 | }
23 |
24 | -(void)setCoordinates:(NSArray *)coordinates
25 | {
26 | _coordinates = coordinates;
27 |
28 | GMSMutablePath *path = [GMSMutablePath path];
29 | for(int i = 0; i < coordinates.count; i++)
30 | {
31 | [path addCoordinate:coordinates[i].coordinate];
32 | }
33 |
34 | _polyline.path = path;
35 | }
36 |
37 | -(void)setStrokeColor:(UIColor *)strokeColor
38 | {
39 | _strokeColor = strokeColor;
40 | _polyline.strokeColor = strokeColor;
41 | }
42 |
43 | -(void)setStrokeWidth:(double)strokeWidth
44 | {
45 | _strokeWidth = strokeWidth;
46 | _polyline.strokeWidth = strokeWidth;
47 | }
48 |
49 | -(void)setFillColor:(UIColor *)fillColor
50 | {
51 | _fillColor = fillColor;
52 | _polyline.spans = @[[GMSStyleSpan spanWithColor:fillColor]];
53 | }
54 |
55 | -(void)setGeodesic:(BOOL)geodesic
56 | {
57 | _geodesic = geodesic;
58 | _polyline.geodesic = geodesic;
59 | }
60 |
61 | -(void)setTitle:(NSString *)title
62 | {
63 | _title = title;
64 | _polyline.title = _title;
65 | }
66 |
67 | -(void) setZIndex:(int)zIndex
68 | {
69 | _zIndex = zIndex;
70 | _polyline.zIndex = zIndex;
71 | }
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolylineManager.h
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 |
7 | #import
8 |
9 | @interface AIRGoogleMapPolylineManager : RCTViewManager
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapPolylineManager.m
3 | //
4 | // Created by Nick Italiano on 10/22/16.
5 | //
6 |
7 | #import "AIRGoogleMapPolylineManager.h"
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import
15 | #import "RCTConvert+MoreMapKit.h"
16 | #import "AIRGoogleMapPolyline.h"
17 |
18 | @interface AIRGoogleMapPolylineManager()
19 |
20 | @end
21 |
22 | @implementation AIRGoogleMapPolylineManager
23 |
24 | RCT_EXPORT_MODULE()
25 |
26 | - (UIView *)view
27 | {
28 | AIRGoogleMapPolyline *polyline = [AIRGoogleMapPolyline new];
29 | return polyline;
30 | }
31 |
32 | RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRMapCoordinateArray)
33 | RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
34 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
35 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, double)
36 | RCT_EXPORT_VIEW_PROPERTY(geodesic, BOOL)
37 | RCT_EXPORT_VIEW_PROPERTY(zIndex, int)
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapURLTileManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapURLTileManager.m
3 | // Created by Nick Italiano on 11/5/16.
4 | //
5 |
6 | #import "AIRGoogleMapUrlTileManager.h"
7 | #import "AIRGoogleMapUrlTile.h"
8 |
9 | @interface AIRGoogleMapUrlTileManager()
10 |
11 | @end
12 |
13 | @implementation AIRGoogleMapUrlTileManager
14 |
15 | RCT_EXPORT_MODULE()
16 |
17 | - (UIView *)view
18 | {
19 | AIRGoogleMapUrlTile *tileLayer = [AIRGoogleMapUrlTile new];
20 | return tileLayer;
21 | }
22 |
23 | RCT_EXPORT_VIEW_PROPERTY(urlTemplate, NSString)
24 | RCT_EXPORT_VIEW_PROPERTY(zIndex, int)
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapUrlTile.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapURLTile.h
3 | // Created by Nick Italiano on 11/5/16.
4 | //
5 |
6 | #import
7 | #import
8 |
9 | @interface AIRGoogleMapUrlTile : UIView
10 |
11 | @property (nonatomic, strong) GMSURLTileLayer *tileLayer;
12 | @property (nonatomic, assign) NSString *urlTemplate;
13 | @property (nonatomic, assign) int zIndex;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapURLTile.m
3 | // Created by Nick Italiano on 11/5/16.
4 | //
5 |
6 | #import "AIRGoogleMapUrlTile.h"
7 |
8 | @implementation AIRGoogleMapUrlTile
9 |
10 | - (void)setZIndex:(int)zIndex
11 | {
12 | _zIndex = zIndex;
13 | _tileLayer.zIndex = zIndex;
14 | }
15 |
16 | - (void)setUrlTemplate:(NSString *)urlTemplate
17 | {
18 | _urlTemplate = urlTemplate;
19 | _tileLayer = [GMSURLTileLayer tileLayerWithURLConstructor:[self _getTileURLConstructor]];
20 | }
21 |
22 | - (GMSTileURLConstructor)_getTileURLConstructor
23 | {
24 | NSString *urlTemplate = self.urlTemplate;
25 | GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
26 | NSString *url = urlTemplate;
27 | url = [url stringByReplacingOccurrencesOfString:@"{x}" withString:[NSString stringWithFormat: @"%ld", (long)x]];
28 | url = [url stringByReplacingOccurrencesOfString:@"{y}" withString:[NSString stringWithFormat: @"%ld", (long)y]];
29 | url = [url stringByReplacingOccurrencesOfString:@"{z}" withString:[NSString stringWithFormat: @"%ld", (long)zoom]];
30 | return [NSURL URLWithString:url];
31 | };
32 | return urls;
33 | }
34 | @end
35 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/AIRGoogleMapUrlTileManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRGoogleMapURLTileManager.h
3 | // Created by Nick Italiano on 11/5/16.
4 | //
5 |
6 | #import
7 | #import
8 |
9 | @interface AIRGoogleMapUrlTileManager : RCTViewManager
10 | @end
11 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/DummyView.h:
--------------------------------------------------------------------------------
1 | //
2 | // DummyView.h
3 | // AirMapsExplorer
4 | //
5 | // Created by Gil Birman on 10/4/16.
6 | //
7 |
8 | #import
9 |
10 |
11 | @interface DummyView : UIView
12 | @property (nonatomic, weak) UIView *view;
13 | - (instancetype)initWithView:(UIView*)view;
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/DummyView.m:
--------------------------------------------------------------------------------
1 | //
2 | // DummyView.m
3 | // AirMapsExplorer
4 | //
5 | // Created by Gil Birman on 10/4/16.
6 | //
7 |
8 | #import
9 | #import "DummyView.h"
10 |
11 | @implementation DummyView
12 | - (instancetype)initWithView:(UIView*)view
13 | {
14 | if ((self = [super init])) {
15 | self.view = view;
16 | }
17 | return self;
18 | }
19 | @end
20 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTConvert+GMSMapViewType.h
3 | //
4 | // Created by Nick Italiano on 10/23/16.
5 | //
6 |
7 | #import
8 | #import
9 | #import
10 |
11 | @interface RCTConvert (GMSMapViewType)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTConvert+GMSMapViewType.m
3 | //
4 | // Created by Nick Italiano on 10/23/16.
5 | //
6 |
7 | #import "RCTConvert+GMSMapViewType.h"
8 | #import
9 | #import
10 |
11 | @implementation RCTConvert (GMSMapViewType)
12 | RCT_ENUM_CONVERTER(GMSMapViewType,
13 | (
14 | @{
15 | @"standard": @(kGMSTypeNormal),
16 | @"hybrid": @(kGMSTypeHybrid),
17 | @"terrain": @(kGMSTypeTerrain),
18 | @"none": @(kGMSTypeNone)
19 | }
20 | ), kGMSTypeTerrain, intValue)
21 | @end
22 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMap.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 | #import
12 |
13 | #import
14 | #import
15 | #import "SMCalloutView.h"
16 |
17 | extern const CLLocationDegrees AIRMapDefaultSpan;
18 | extern const NSTimeInterval AIRMapRegionChangeObserveInterval;
19 | extern const CGFloat AIRMapZoomBoundBuffer;
20 |
21 | @interface AIRMap: MKMapView
22 |
23 | @property (nonatomic, strong) SMCalloutView *calloutView;
24 | @property (nonatomic, strong) UIImageView *cacheImageView;
25 | @property (nonatomic, strong) UIView *loadingView;
26 |
27 | @property (nonatomic, assign) BOOL followUserLocation;
28 | @property (nonatomic, assign) BOOL hasStartedRendering;
29 | @property (nonatomic, assign) BOOL cacheEnabled;
30 | @property (nonatomic, assign) BOOL loadingEnabled;
31 | @property (nonatomic, strong) UIColor *loadingBackgroundColor;
32 | @property (nonatomic, strong) UIColor *loadingIndicatorColor;
33 | @property (nonatomic, assign) BOOL hasShownInitialLoading;
34 | @property (nonatomic, assign) CGFloat minDelta;
35 | @property (nonatomic, assign) CGFloat maxDelta;
36 | @property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
37 | @property (nonatomic, strong) NSTimer *regionChangeObserveTimer;
38 | @property (nonatomic, assign) MKCoordinateRegion initialRegion;
39 |
40 | @property (nonatomic, assign) CLLocationCoordinate2D pendingCenter;
41 | @property (nonatomic, assign) MKCoordinateSpan pendingSpan;
42 |
43 |
44 | @property (nonatomic, assign) BOOL ignoreRegionChanges;
45 |
46 | @property (nonatomic, copy) RCTBubblingEventBlock onChange;
47 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
48 | @property (nonatomic, copy) RCTBubblingEventBlock onPanDrag;
49 | @property (nonatomic, copy) RCTBubblingEventBlock onLongPress;
50 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerPress;
51 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerSelect;
52 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDeselect;
53 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDragStart;
54 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDrag;
55 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDragEnd;
56 | @property (nonatomic, copy) RCTDirectEventBlock onCalloutPress;
57 | @property (nonatomic, copy) RCTDirectEventBlock onRegionChange;
58 |
59 | - (void)cacheViewIfNeeded;
60 | - (void)beginLoading;
61 | - (void)finishLoading;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCallout.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 | #import
8 |
9 |
10 | @interface AIRMapCallout : RCTView
11 |
12 | @property (nonatomic, assign) BOOL tooltip;
13 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCallout.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import "AIRMapCallout.h"
7 |
8 |
9 | @implementation AIRMapCallout {
10 |
11 | }
12 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCalloutManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 |
9 | @interface AIRMapCalloutManager : RCTViewManager
10 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCalloutManager.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AIRMapCalloutManager.h"
11 |
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 | #import
18 | #import "AIRMapMarker.h"
19 | #import "AIRMapCallout.h"
20 |
21 | @interface AIRMapCalloutManager()
22 |
23 | @end
24 |
25 | @implementation AIRMapCalloutManager
26 |
27 | RCT_EXPORT_MODULE()
28 |
29 | - (UIView *)view
30 | {
31 | return [AIRMapCallout new];
32 | }
33 |
34 | RCT_EXPORT_VIEW_PROPERTY(tooltip, BOOL)
35 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCircle.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | #import
9 | #import
10 |
11 | #import
12 | #import
13 | #import
14 |
15 | #import "AIRMapCoordinate.h"
16 | #import "AIRMap.h"
17 |
18 | @interface AIRMapCircle: MKAnnotationView
19 |
20 | @property (nonatomic, weak) AIRMap *map;
21 |
22 | @property (nonatomic, strong) MKCircle *circle;
23 | @property (nonatomic, strong) MKCircleRenderer *renderer;
24 |
25 | @property (nonatomic, assign) CLLocationCoordinate2D centerCoordinate;
26 | @property (nonatomic, assign) CLLocationDistance radius;
27 |
28 | @property (nonatomic, strong) UIColor *fillColor;
29 | @property (nonatomic, strong) UIColor *strokeColor;
30 | @property (nonatomic, assign) CGFloat strokeWidth;
31 | @property (nonatomic, assign) CGFloat miterLimit;
32 | @property (nonatomic, assign) CGLineCap lineCap;
33 | @property (nonatomic, assign) CGLineJoin lineJoin;
34 | @property (nonatomic, assign) CGFloat lineDashPhase;
35 | @property (nonatomic, strong) NSArray *lineDashPattern;
36 |
37 | #pragma mark MKOverlay protocol
38 |
39 | @property(nonatomic, readonly) CLLocationCoordinate2D coordinate;
40 | @property(nonatomic, readonly) MKMapRect boundingMapRect;
41 | - (BOOL)intersectsMapRect:(MKMapRect)mapRect;
42 | - (BOOL)canReplaceMapContent;
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCircle.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import "AIRMapCircle.h"
7 | #import
8 |
9 |
10 | @implementation AIRMapCircle {
11 | BOOL _radiusSet;
12 | BOOL _centerSet;
13 | }
14 |
15 | - (void)setFillColor:(UIColor *)fillColor {
16 | _fillColor = fillColor;
17 | [self update];
18 | }
19 |
20 | - (void)setStrokeColor:(UIColor *)strokeColor {
21 | _strokeColor = strokeColor;
22 | [self update];
23 | }
24 |
25 | - (void)setStrokeWidth:(CGFloat)strokeWidth {
26 | _strokeWidth = strokeWidth;
27 | [self update];
28 | }
29 |
30 | - (void)setLineJoin:(CGLineJoin)lineJoin {
31 | _lineJoin = lineJoin;
32 | [self update];
33 | }
34 |
35 | - (void)setLineCap:(CGLineCap)lineCap {
36 | _lineCap = lineCap;
37 | [self update];
38 | }
39 |
40 | - (void)setMiterLimit:(CGFloat)miterLimit {
41 | _miterLimit = miterLimit;
42 | [self update];
43 | }
44 |
45 | - (void)setLineDashPhase:(CGFloat)lineDashPhase {
46 | _lineDashPhase = lineDashPhase;
47 | [self update];
48 | }
49 |
50 | - (void)setLineDashPattern:(NSArray *)lineDashPattern {
51 | _lineDashPattern = lineDashPattern;
52 | [self update];
53 | }
54 |
55 | - (void)setRadius:(CLLocationDistance)radius {
56 | _radius = radius;
57 | _radiusSet = YES;
58 | [self createCircleAndRendererIfPossible];
59 | [self update];
60 | }
61 |
62 | - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate{
63 | _centerCoordinate = centerCoordinate;
64 | _centerSet = YES;
65 | [self createCircleAndRendererIfPossible];
66 | [self update];
67 | }
68 |
69 | - (void) createCircleAndRendererIfPossible
70 | {
71 | if (!_centerSet || !_radiusSet) return;
72 | self.circle = [MKCircle circleWithCenterCoordinate:_centerCoordinate radius:_radius];
73 | self.renderer = [[MKCircleRenderer alloc] initWithCircle:self.circle];
74 | }
75 |
76 | - (void) update
77 | {
78 | if (!_renderer) return;
79 | _renderer.fillColor = _fillColor;
80 | _renderer.strokeColor = _strokeColor;
81 | _renderer.lineWidth = _strokeWidth;
82 | _renderer.lineCap = _lineCap;
83 | _renderer.lineJoin = _lineJoin;
84 | _renderer.miterLimit = _miterLimit;
85 | _renderer.lineDashPhase = _lineDashPhase;
86 | _renderer.lineDashPattern = _lineDashPattern;
87 |
88 | if (_map == nil) return;
89 | [_map removeOverlay:self];
90 | [_map addOverlay:self];
91 | }
92 |
93 |
94 | #pragma mark MKOverlay implementation
95 |
96 | - (CLLocationCoordinate2D) coordinate
97 | {
98 | return self.circle.coordinate;
99 | }
100 |
101 | - (MKMapRect) boundingMapRect
102 | {
103 | return self.circle.boundingMapRect;
104 | }
105 |
106 | - (BOOL)intersectsMapRect:(MKMapRect)mapRect
107 | {
108 | BOOL answer = [self.circle intersectsMapRect:mapRect];
109 | return answer;
110 | }
111 |
112 | - (BOOL)canReplaceMapContent
113 | {
114 | return NO;
115 | }
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCircleManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 |
9 | @interface AIRMapCircleManager : RCTViewManager
10 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCircleManager.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AIRMapCircleManager.h"
11 |
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 | #import
18 | #import "AIRMapMarker.h"
19 | #import "AIRMapCircle.h"
20 |
21 | @interface AIRMapCircleManager()
22 |
23 | @end
24 |
25 | @implementation AIRMapCircleManager
26 |
27 | RCT_EXPORT_MODULE()
28 |
29 | - (UIView *)view
30 | {
31 | AIRMapCircle *circle = [AIRMapCircle new];
32 | return circle;
33 | }
34 |
35 | RCT_REMAP_VIEW_PROPERTY(center, centerCoordinate, CLLocationCoordinate2D)
36 | RCT_EXPORT_VIEW_PROPERTY(radius, CLLocationDistance)
37 | RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
38 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
39 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, CGFloat)
40 | RCT_EXPORT_VIEW_PROPERTY(lineCap, CGLineCap)
41 | RCT_EXPORT_VIEW_PROPERTY(lineJoin, CGLineJoin)
42 | RCT_EXPORT_VIEW_PROPERTY(miterLimit, CGFloat)
43 | RCT_EXPORT_VIEW_PROPERTY(lineDashPhase, CGFloat)
44 | RCT_EXPORT_VIEW_PROPERTY(lineDashPattern, NSArray)
45 |
46 | // NOTE(lmr):
47 | // for now, onPress events for overlays will be left unimplemented. Seems it is possible with some work, but
48 | // it is difficult to achieve in both ios and android so I decided to leave it out.
49 | //RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCoordinate.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 | #import
8 |
9 | @interface AIRMapCoordinate : NSObject
10 |
11 | @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
12 |
13 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapCoordinate.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import "AIRMapCoordinate.h"
7 |
8 |
9 | @implementation AIRMapCoordinate {
10 |
11 | }
12 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapManager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | @interface AIRMapManager : RCTViewManager
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapMarker.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AIRMapMarker.h"
11 | #import "AIRMapCallout.h"
12 |
13 | #import
14 | #import
15 |
16 | #import
17 | #import
18 | #import "AIRMap.h"
19 | #import "SMCalloutView.h"
20 |
21 | @class RCTBridge;
22 |
23 | @interface AIRMapMarker : MKAnnotationView
24 |
25 | @property (nonatomic, strong) AIRMapCallout *calloutView;
26 | @property (nonatomic, weak) AIRMap *map;
27 | @property (nonatomic, weak) RCTBridge *bridge;
28 |
29 | @property (nonatomic, strong) NSString *identifier;
30 | @property (nonatomic, copy) NSString *imageSrc;
31 | @property (nonatomic, copy) NSString *title;
32 | @property (nonatomic, copy) NSString *subtitle;
33 | @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
34 | @property (nonatomic, strong) UIColor *pinColor;
35 | @property (nonatomic, assign) NSInteger zIndex;
36 | @property (nonatomic, assign) double opacity;
37 |
38 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
39 | @property (nonatomic, copy) RCTDirectEventBlock onSelect;
40 | @property (nonatomic, copy) RCTDirectEventBlock onDeselect;
41 | @property (nonatomic, copy) RCTDirectEventBlock onCalloutPress;
42 | @property (nonatomic, copy) RCTDirectEventBlock onDragStart;
43 | @property (nonatomic, copy) RCTDirectEventBlock onDrag;
44 | @property (nonatomic, copy) RCTDirectEventBlock onDragEnd;
45 |
46 |
47 | - (MKAnnotationView *)getAnnotationView;
48 | - (void)fillCalloutView:(SMCalloutView *)calloutView;
49 | - (BOOL)shouldShowCalloutView;
50 | - (void)showCalloutView;
51 | - (void)hideCalloutView;
52 | - (void)addTapGestureRecognizer;
53 |
54 | @end
55 |
56 |
57 | @interface AIREmptyCalloutBackgroundView : SMCalloutBackgroundView
58 | @end
59 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapMarkerManager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | @interface AIRMapMarkerManager : RCTViewManager
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapMarkerManager.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AIRMapMarkerManager.h"
11 |
12 | #import
13 | #import
14 | #import
15 | #import "AIRMapMarker.h"
16 |
17 | @interface AIRMapMarkerManager ()
18 |
19 | @end
20 |
21 | @implementation AIRMapMarkerManager
22 |
23 | RCT_EXPORT_MODULE()
24 |
25 | - (UIView *)view
26 | {
27 | AIRMapMarker *marker = [AIRMapMarker new];
28 | [marker addTapGestureRecognizer];
29 | marker.bridge = self.bridge;
30 | return marker;
31 | }
32 |
33 | RCT_EXPORT_VIEW_PROPERTY(identifier, NSString)
34 | //RCT_EXPORT_VIEW_PROPERTY(reuseIdentifier, NSString)
35 | RCT_EXPORT_VIEW_PROPERTY(title, NSString)
36 | RCT_REMAP_VIEW_PROPERTY(description, subtitle, NSString)
37 | RCT_EXPORT_VIEW_PROPERTY(coordinate, CLLocationCoordinate2D)
38 | RCT_EXPORT_VIEW_PROPERTY(centerOffset, CGPoint)
39 | RCT_EXPORT_VIEW_PROPERTY(calloutOffset, CGPoint)
40 | RCT_REMAP_VIEW_PROPERTY(image, imageSrc, NSString)
41 | RCT_EXPORT_VIEW_PROPERTY(pinColor, UIColor)
42 | RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
43 | RCT_EXPORT_VIEW_PROPERTY(zIndex, NSInteger)
44 | RCT_EXPORT_VIEW_PROPERTY(opacity, double)
45 |
46 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
47 | RCT_EXPORT_VIEW_PROPERTY(onSelect, RCTDirectEventBlock)
48 | RCT_EXPORT_VIEW_PROPERTY(onDeselect, RCTDirectEventBlock)
49 | RCT_EXPORT_VIEW_PROPERTY(onCalloutPress, RCTDirectEventBlock)
50 | RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTDirectEventBlock)
51 | RCT_EXPORT_VIEW_PROPERTY(onDrag, RCTDirectEventBlock)
52 | RCT_EXPORT_VIEW_PROPERTY(onDragEnd, RCTDirectEventBlock)
53 |
54 |
55 | RCT_EXPORT_METHOD(showCallout:(nonnull NSNumber *)reactTag)
56 | {
57 | [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) {
58 | id view = viewRegistry[reactTag];
59 | if (![view isKindOfClass:[AIRMapMarker class]]) {
60 | RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
61 | } else {
62 | [(AIRMapMarker *) view showCalloutView];
63 | }
64 | }];
65 | }
66 |
67 | RCT_EXPORT_METHOD(hideCallout:(nonnull NSNumber *)reactTag)
68 | {
69 | [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) {
70 | id view = viewRegistry[reactTag];
71 | if (![view isKindOfClass:[AIRMapMarker class]]) {
72 | RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
73 | } else {
74 | [(AIRMapMarker *) view hideCalloutView];
75 | }
76 | }];
77 | }
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapPolygon.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | #import
9 | #import
10 |
11 | #import
12 | #import
13 | #import
14 | #import "AIRMapCoordinate.h"
15 | #import "AIRMap.h"
16 |
17 |
18 |
19 | @interface AIRMapPolygon: MKAnnotationView
20 |
21 | @property (nonatomic, weak) AIRMap *map;
22 |
23 | @property (nonatomic, strong) MKPolygon *polygon;
24 | @property (nonatomic, strong) MKPolygonRenderer *renderer;
25 | @property (nonatomic, strong) NSArray *interiorPolygons;
26 |
27 | @property (nonatomic, strong) NSArray *coordinates;
28 | @property (nonatomic, strong) NSArray *> *holes;
29 | @property (nonatomic, strong) UIColor *fillColor;
30 | @property (nonatomic, strong) UIColor *strokeColor;
31 | @property (nonatomic, assign) CGFloat strokeWidth;
32 | @property (nonatomic, assign) CGFloat miterLimit;
33 | @property (nonatomic, assign) CGLineCap lineCap;
34 | @property (nonatomic, assign) CGLineJoin lineJoin;
35 | @property (nonatomic, assign) CGFloat lineDashPhase;
36 | @property (nonatomic, strong) NSArray *lineDashPattern;
37 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
38 |
39 | #pragma mark MKOverlay protocol
40 |
41 | @property(nonatomic, readonly) CLLocationCoordinate2D coordinate;
42 | @property(nonatomic, readonly) MKMapRect boundingMapRect;
43 | - (BOOL)intersectsMapRect:(MKMapRect)mapRect;
44 | - (BOOL)canReplaceMapContent;
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapPolygonManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 |
9 | @interface AIRMapPolygonManager : RCTViewManager
10 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapPolygonManager.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AIRMapPolygonManager.h"
11 |
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 | #import
18 | #import "RCTConvert+MoreMapKit.h"
19 | #import "AIRMapMarker.h"
20 | #import "AIRMapPolygon.h"
21 |
22 | @interface AIRMapPolygonManager()
23 |
24 | @end
25 |
26 | @implementation AIRMapPolygonManager
27 |
28 | RCT_EXPORT_MODULE()
29 |
30 | - (UIView *)view
31 | {
32 | AIRMapPolygon *polygon = [AIRMapPolygon new];
33 | return polygon;
34 | }
35 |
36 | RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRMapCoordinateArray)
37 | RCT_EXPORT_VIEW_PROPERTY(holes, AIRMapCoordinateArrayArray)
38 | RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
39 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
40 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, CGFloat)
41 | RCT_EXPORT_VIEW_PROPERTY(lineCap, CGLineCap)
42 | RCT_EXPORT_VIEW_PROPERTY(lineJoin, CGLineJoin)
43 | RCT_EXPORT_VIEW_PROPERTY(miterLimit, CGFloat)
44 | RCT_EXPORT_VIEW_PROPERTY(lineDashPhase, CGFloat)
45 | RCT_EXPORT_VIEW_PROPERTY(lineDashPattern, NSArray)
46 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
47 |
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapPolyline.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | #import
9 | #import
10 |
11 | #import
12 | #import
13 | #import
14 | #import "AIRMapCoordinate.h"
15 | #import "AIRMap.h"
16 |
17 |
18 | @interface AIRMapPolyline: MKAnnotationView
19 |
20 | @property (nonatomic, weak) AIRMap *map;
21 |
22 | @property (nonatomic, strong) MKPolyline *polyline;
23 | @property (nonatomic, strong) MKPolylineRenderer *renderer;
24 |
25 | @property (nonatomic, strong) NSArray *coordinates;
26 | @property (nonatomic, strong) UIColor *fillColor;
27 | @property (nonatomic, strong) UIColor *strokeColor;
28 | @property (nonatomic, assign) CGFloat strokeWidth;
29 | @property (nonatomic, assign) CGFloat miterLimit;
30 | @property (nonatomic, assign) CGLineCap lineCap;
31 | @property (nonatomic, assign) CGLineJoin lineJoin;
32 | @property (nonatomic, assign) CGFloat lineDashPhase;
33 | @property (nonatomic, strong) NSArray *lineDashPattern;
34 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
35 |
36 | #pragma mark MKOverlay protocol
37 |
38 | @property(nonatomic, readonly) CLLocationCoordinate2D coordinate;
39 | @property(nonatomic, readonly) MKMapRect boundingMapRect;
40 | - (BOOL)intersectsMapRect:(MKMapRect)mapRect;
41 | - (BOOL)canReplaceMapContent;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapPolylineManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 |
9 | @interface AIRMapPolylineManager : RCTViewManager
10 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapPolylineManager.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AIRMapPolylineManager.h"
11 |
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 | #import
18 | #import "RCTConvert+MoreMapKit.h"
19 | #import "AIRMapMarker.h"
20 | #import "AIRMapPolyline.h"
21 |
22 | @interface AIRMapPolylineManager()
23 |
24 | @end
25 |
26 | @implementation AIRMapPolylineManager
27 |
28 | RCT_EXPORT_MODULE()
29 |
30 | - (UIView *)view
31 | {
32 | AIRMapPolyline *polyline = [AIRMapPolyline new];
33 | return polyline;
34 | }
35 |
36 | RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRMapCoordinateArray)
37 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
38 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, CGFloat)
39 | RCT_EXPORT_VIEW_PROPERTY(lineCap, CGLineCap)
40 | RCT_EXPORT_VIEW_PROPERTY(lineJoin, CGLineJoin)
41 | RCT_EXPORT_VIEW_PROPERTY(miterLimit, CGFloat)
42 | RCT_EXPORT_VIEW_PROPERTY(lineDashPhase, CGFloat)
43 | RCT_EXPORT_VIEW_PROPERTY(lineDashPattern, NSArray)
44 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapSnapshot.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRMapSnapshot.h
3 | // AirMaps
4 | //
5 | // Created by Hein Rutjes on 26/09/16.
6 | // Copyright © 2016 Christopher. All rights reserved.
7 | //
8 |
9 | #ifndef AIRMapSnapshot_h
10 | #define AIRMapSnapshot_h
11 |
12 | @protocol AIRMapSnapshot
13 | @optional
14 | - (void) drawToSnapshot:(MKMapSnapshot *) snapshot context:(CGContextRef) context;
15 | @end
16 |
17 | #endif /* AIRMapSnapshot_h */
18 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapUrlTile.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRUrlTileOverlay.h
3 | // AirMaps
4 | //
5 | // Created by cascadian on 3/19/16.
6 | // Copyright © 2016. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | #import
14 | #import
15 | #import
16 | #import "AIRMapCoordinate.h"
17 | #import "AIRMap.h"
18 |
19 | @interface AIRMapUrlTile : MKAnnotationView
20 |
21 | @property (nonatomic, weak) AIRMap *map;
22 |
23 | @property (nonatomic, strong) MKTileOverlay *tileOverlay;
24 | @property (nonatomic, strong) MKTileOverlayRenderer *renderer;
25 |
26 | @property (nonatomic, copy) NSString *urlTemplate;
27 |
28 | #pragma mark MKOverlay protocol
29 |
30 | @property(nonatomic, readonly) CLLocationCoordinate2D coordinate;
31 | @property(nonatomic, readonly) MKMapRect boundingMapRect;
32 | //- (BOOL)intersectsMapRect:(MKMapRect)mapRect;
33 | - (BOOL)canReplaceMapContent;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapUrlTile.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRUrlTileOverlay.m
3 | // AirMaps
4 | //
5 | // Created by cascadian on 3/19/16.
6 | // Copyright © 2016. All rights reserved.
7 | //
8 |
9 | #import "AIRMapUrlTile.h"
10 | #import
11 |
12 | @implementation AIRMapUrlTile {
13 | BOOL _urlTemplateSet;
14 | }
15 |
16 |
17 | - (void)setUrlTemplate:(NSString *)urlTemplate{
18 | _urlTemplate = urlTemplate;
19 | _urlTemplateSet = YES;
20 | [self createTileOverlayAndRendererIfPossible];
21 | [self update];
22 | }
23 |
24 | - (void) createTileOverlayAndRendererIfPossible
25 | {
26 | if (!_urlTemplateSet) return;
27 | self.tileOverlay = [[MKTileOverlay alloc] initWithURLTemplate:self.urlTemplate];
28 | self.tileOverlay.canReplaceMapContent = YES;
29 | self.renderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:self.tileOverlay];
30 | }
31 |
32 | - (void) update
33 | {
34 | if (!_renderer) return;
35 |
36 | if (_map == nil) return;
37 | [_map removeOverlay:self];
38 | [_map addOverlay:self level:MKOverlayLevelAboveLabels];
39 | }
40 |
41 | #pragma mark MKOverlay implementation
42 |
43 | - (CLLocationCoordinate2D) coordinate
44 | {
45 | return self.tileOverlay.coordinate;
46 | }
47 |
48 | - (MKMapRect) boundingMapRect
49 | {
50 | return self.tileOverlay.boundingMapRect;
51 | }
52 |
53 | - (BOOL)canReplaceMapContent
54 | {
55 | return self.tileOverlay.canReplaceMapContent;
56 | }
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapUrlTileManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // AIRMapUrlTileManager.h
3 | // AirMaps
4 | //
5 | // Created by cascadian on 3/19/16.
6 | // Copyright © 2016. All rights reserved.
7 | //
8 |
9 |
10 | #import
11 |
12 | @interface AIRMapUrlTileManager : RCTViewManager
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/AirMaps/AIRMapUrlTileManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // AIRMapUrlTileManager.m
3 | // AirMaps
4 | //
5 | // Created by cascadian on 3/19/16.
6 | // Copyright © 2016. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import
15 | #import "AIRMapMarker.h"
16 | #import "AIRMapUrlTile.h"
17 |
18 | #import "AIRMapUrlTileManager.h"
19 |
20 | @interface AIRMapUrlTileManager()
21 |
22 | @end
23 |
24 | @implementation AIRMapUrlTileManager
25 |
26 |
27 | RCT_EXPORT_MODULE()
28 |
29 | - (UIView *)view
30 | {
31 | AIRMapUrlTile *tile = [AIRMapUrlTile new];
32 | return tile;
33 | }
34 |
35 | RCT_EXPORT_VIEW_PROPERTY(urlTemplate, NSString)
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/ios/AirMaps/RCTConvert+MoreMapKit.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import
7 | #import
8 | #import
9 |
10 | @interface RCTConvert (MoreMapKit)
11 |
12 | @end
--------------------------------------------------------------------------------
/ios/AirMaps/RCTConvert+MoreMapKit.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Leland Richardson on 12/27/15.
3 | // Copyright (c) 2015 Facebook. All rights reserved.
4 | //
5 |
6 | #import "RCTConvert+MoreMapKit.h"
7 |
8 | #import
9 | #import "AIRMapCoordinate.h"
10 |
11 | @implementation RCTConvert (MoreMapKit)
12 |
13 | // NOTE(lmr):
14 | // This is a bit of a hack, but I'm using this class to simply wrap
15 | // around a `CLLocationCoordinate2D`, since I was unable to figure out
16 | // how to handle an array of structs like CLLocationCoordinate2D. Would love
17 | // to get rid of this if someone can show me how...
18 | + (AIRMapCoordinate *)AIRMapCoordinate:(id)json
19 | {
20 | AIRMapCoordinate *coord = [AIRMapCoordinate new];
21 | coord.coordinate = [self CLLocationCoordinate2D:json];
22 | return coord;
23 | }
24 |
25 | RCT_ARRAY_CONVERTER(AIRMapCoordinate)
26 |
27 | + (NSArray *> *)AIRMapCoordinateArrayArray:(id)json
28 | {
29 | return RCTConvertArrayValue(@selector(AIRMapCoordinateArray:), json);
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-maps",
3 | "description": "React Native Mapview component for iOS + Android",
4 | "main": "index.js",
5 | "author": "Leland Richardson ",
6 | "version": "0.13.0",
7 | "scripts": {
8 | "start": "react-native start",
9 | "lint": "eslint .",
10 | "preversion": "./scripts/update-version.js"
11 | },
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/airbnb/react-native-maps"
15 | },
16 | "keywords": [
17 | "react",
18 | "react-native",
19 | "react-component",
20 | "map",
21 | "mapview",
22 | "google-maps",
23 | "mapkit"
24 | ],
25 | "peerDependencies": {
26 | "react": ">=15.4.0",
27 | "react-native": "^0.41.2"
28 | },
29 | "devDependencies": {
30 | "babel-eslint": "^6.1.2",
31 | "eslint": "^3.3.1",
32 | "eslint-config-airbnb": "^10.0.1",
33 | "eslint-plugin-import": "^1.14.0",
34 | "eslint-plugin-jsx-a11y": "^2.1.0",
35 | "eslint-plugin-prefer-object-spread": "^1.1.0",
36 | "eslint-plugin-react": "^6.1.2"
37 |
38 | },
39 | "rnpm": {
40 | "android": {
41 | "sourceDir": "./android"
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/react-native-google-maps.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = "react-native-google-maps"
3 | s.version = "0.13.0"
4 | s.summary = "React Native Mapview component for iOS + Android"
5 |
6 | s.authors = { "intelligibabble" => "leland.m.richardson@gmail.com" }
7 | s.homepage = "https://github.com/airbnb/react-native-maps#readme"
8 | s.license = "MIT"
9 | s.platform = :ios, "8.0"
10 |
11 | s.source = { :git => "https://github.com/airbnb/react-native-maps.git" }
12 | s.source_files = "ios/AirGoogleMaps/**/*.{h,m}"
13 |
14 | s.dependency 'React'
15 | s.dependency 'GoogleMaps', '2.1.1'
16 | end
17 |
--------------------------------------------------------------------------------
/react-native-maps.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = "react-native-maps"
3 | s.version = "0.13.0"
4 | s.summary = "React Native Mapview component for iOS + Android"
5 |
6 | s.authors = { "intelligibabble" => "leland.m.richardson@gmail.com" }
7 | s.homepage = "https://github.com/airbnb/react-native-maps#readme"
8 | s.license = "MIT"
9 | s.platform = :ios, "8.0"
10 |
11 | s.source = { :git => "https://github.com/airbnb/react-native-maps.git" }
12 | s.source_files = "ios/AirMaps/**/*.{h,m}"
13 |
14 | s.dependency 'React'
15 | end
16 |
--------------------------------------------------------------------------------
/scripts/update-version.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /**
4 | * Script that runs as part of `npm version`. It updates any files that have a
5 | * reference to the current package version:
6 | *
7 | * - android/gradle.properties
8 | * - react-native-maps.podspec
9 | * - react-native-google-maps.podspec
10 | *
11 | * And `git add`s them.
12 | */
13 |
14 | const { exec } = require('child_process');
15 | const pkg = require('../package.json');
16 |
17 | const filesToUpdate = [
18 | 'android/gradle.properties',
19 | 'react-native-maps.podspec',
20 | 'react-native-google-maps.podspec',
21 | ];
22 |
23 | function doExec(cmdString) {
24 | return new Promise((resolve, reject) => {
25 | exec(cmdString, (err, stdout) => {
26 | if (err) {
27 | reject(err);
28 | return;
29 | }
30 | resolve(stdout);
31 | });
32 | });
33 | }
34 |
35 | function updateVersionInFile(currentVersion, nextVersion, relativePath) {
36 | process.stdout.write(`• ${relativePath}\n`);
37 | return doExec(`sed -i '' 's/${
38 | escapeDots(currentVersion)
39 | }/${
40 | escapeDots(nextVersion)
41 | }/g' ./${relativePath}`);
42 | }
43 |
44 | function escapeDots(version) {
45 | return version.replace(/\./g, '\\.');
46 | }
47 |
48 | function run() {
49 | const currentVersion = pkg.version;
50 | const nextVersion = process.env.npm_package_version;
51 |
52 | Promise.resolve()
53 | .then(() => updateFiles(currentVersion, nextVersion))
54 | .then(() => gitAdd());
55 | }
56 |
57 | // Tasks
58 |
59 | function updateFiles(currentVersion, nextVersion) {
60 | process.stdout.write(`Updating ${currentVersion} ➞ ${nextVersion}:\n`);
61 | return Promise.all(filesToUpdate.map(relativePath =>
62 | updateVersionInFile(currentVersion, nextVersion, relativePath)
63 | ));
64 | }
65 |
66 | function gitAdd() {
67 | return doExec(`git add ${filesToUpdate.join(' ')}`);
68 | }
69 |
70 | // Do it.
71 |
72 | run();
73 |
--------------------------------------------------------------------------------