├── .bundle └── config ├── .eslintignore ├── .eslintrc ├── .flowconfig ├── .github ├── ISSUE_TEMPLATE.md └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── .idea └── codeStyleSettings.xml ├── .jscodeshiftignore ├── .npmignore ├── .project ├── .settings └── org.eclipse.buildship.core.prefs ├── .travis.yml ├── .watchmanconfig ├── CHANGELOG.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── _config.yml ├── build.gradle ├── circle.yml ├── docs ├── callout.md ├── circle.md ├── examples-setup.md ├── installation.md ├── mapview.md ├── marker.md ├── polygon.md └── polyline.md ├── example ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── rnosm │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── rnosm │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.tsx ├── ios │ ├── File.swift │ ├── Podfile │ ├── RnOsmExample-Bridging-Header.h │ ├── RnOsmExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── RnOsmExample.xcscheme │ ├── RnOsmExample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── RnOsmExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m ├── metro.config.js ├── package.json ├── src │ └── App.tsx └── yarn.lock ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── index.d.ts ├── index.js ├── lib ├── android │ ├── .classpath │ ├── .project │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── airbnb │ │ │ └── android │ │ │ └── react │ │ │ └── maps │ │ │ ├── MapsPackage.java │ │ │ └── open │ │ │ ├── Bounds.java │ │ │ ├── LatLngBoundsUtils.java │ │ │ ├── OpenAirMapFeature.java │ │ │ ├── OpenAirMapManager.java │ │ │ ├── OpenAirMapModule.java │ │ │ ├── OpenAirMapView.java │ │ │ ├── OpenMapPackager.java │ │ │ ├── SizeReportingShadowNode.java │ │ │ ├── collout │ │ │ ├── OpenAirMapCallout.java │ │ │ └── OpenAirMapCalloutManager.java │ │ │ ├── marker │ │ │ ├── OpenAirMapMarker.java │ │ │ └── OpenAirMapMarkerManager.java │ │ │ └── polyline │ │ │ ├── OpenAirMapPolyline.java │ │ │ └── OpenAirMapPolylineManager.java │ │ └── res │ │ └── values │ │ └── colors.xml ├── components │ ├── MapMarker.js │ ├── MapPolygon.js │ ├── MapPolyline.js │ ├── MapView.js │ ├── ProviderConstants.js │ └── decorateMapComponent.js └── ios │ ├── AirGoogleMaps │ ├── AIRGMSMarker.h │ ├── AIRGMSMarker.m │ ├── AIRGMSPolygon.h │ ├── AIRGMSPolygon.m │ ├── AIRGMSPolyline.h │ ├── AIRGMSPolyline.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 │ ├── AIRMapLocalTile.h │ ├── AIRMapLocalTile.m │ ├── AIRMapLocalTileManager.h │ ├── AIRMapLocalTileManager.m │ ├── AIRMapLocalTileOverlay.h │ ├── AIRMapLocalTileOverlay.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 │ ├── AIRMapPolylineRenderer.h │ ├── AIRMapPolylineRenderer.m │ ├── AIRMapSnapshot.h │ ├── AIRMapUrlTile.h │ ├── AIRMapUrlTile.m │ ├── AIRMapUrlTileManager.h │ ├── AIRMapUrlTileManager.m │ ├── Callout │ ├── SMCalloutView.h │ └── SMCalloutView.m │ ├── RCTConvert+AirMap.h │ └── RCTConvert+AirMap.m ├── package.json ├── react-native-google-maps.podspec ├── react-native-maps.podspec ├── rn-cli.config.js ├── scripts └── update-version.js ├── settings.gradle └── yarn.lock /.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_BIN: "./examples/ios" 3 | -------------------------------------------------------------------------------- /.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-extraneous-dependencies": 0, 15 | "import/no-unresolved": [2, { "ignore": ["^react-native-maps"] }] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | ### Is this a bug report? 23 | 24 | (write your answer here) 25 | 26 | 40 | 41 | ### Have you read the [Installation Instructions](https://github.com/react-community/react-native-maps/blob/master/docs/installation.md)? 42 | 43 | (Write your answer here.) 44 | 45 | ### Environment 46 | 47 | 60 | 61 | ### Steps to Reproduce 62 | 63 | 68 | 69 | (Write your steps here:) 70 | 71 | 1. 2. 3. 72 | 73 | ### Expected Behavior 74 | 75 | 80 | 81 | (Write what you thought would happen.) 82 | 83 | ### Actual Behavior 84 | 85 | 91 | 92 | (Write what happened. Add screenshots!) 93 | 94 | ### Reproducible Demo 95 | 96 | 109 | 110 | (Paste the link to an example project and exact instructions to reproduce the issue.) 111 | 112 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | 5 | --- 6 | 7 | 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.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 | lib/android/src/main/gen 39 | example/android/app/src/main/gen 40 | example/node_modules 41 | -------------------------------------------------------------------------------- /.jscodeshiftignore: -------------------------------------------------------------------------------- 1 | # To run a codeshift on the react-native-maps library, cd to the root dir and run: 2 | # jscodeshift -t PATH_TO_TRANSFORM . --ignore-config .jscodeshiftignore 3 | .idea 4 | android 5 | docs 6 | example 7 | gradle 8 | node_modules 9 | scripts -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | example 2 | .babelrc 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | react-native-maps 4 | Project react-native-maps created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | #Thu Dec 28 16:10:57 GMT-03:00 2017 2 | connection.project.dir= 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "6" 5 | 6 | cache: 7 | directories: 8 | - node_modules 9 | 10 | script: npm run ci 11 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'cocoapods' 3 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | CFPropertyList (2.3.6) 5 | activesupport (4.2.10) 6 | i18n (~> 0.7) 7 | minitest (~> 5.1) 8 | thread_safe (~> 0.3, >= 0.3.4) 9 | tzinfo (~> 1.1) 10 | claide (1.0.2) 11 | cocoapods (1.3.1) 12 | activesupport (>= 4.0.2, < 5) 13 | claide (>= 1.0.2, < 2.0) 14 | cocoapods-core (= 1.3.1) 15 | cocoapods-deintegrate (>= 1.0.1, < 2.0) 16 | cocoapods-downloader (>= 1.1.3, < 2.0) 17 | cocoapods-plugins (>= 1.0.0, < 2.0) 18 | cocoapods-search (>= 1.0.0, < 2.0) 19 | cocoapods-stats (>= 1.0.0, < 2.0) 20 | cocoapods-trunk (>= 1.2.0, < 2.0) 21 | cocoapods-try (>= 1.1.0, < 2.0) 22 | colored2 (~> 3.1) 23 | escape (~> 0.0.4) 24 | fourflusher (~> 2.0.1) 25 | gh_inspector (~> 1.0) 26 | molinillo (~> 0.5.7) 27 | nap (~> 1.0) 28 | ruby-macho (~> 1.1) 29 | xcodeproj (>= 1.5.1, < 2.0) 30 | cocoapods-core (1.3.1) 31 | activesupport (>= 4.0.2, < 6) 32 | fuzzy_match (~> 2.0.4) 33 | nap (~> 1.0) 34 | cocoapods-deintegrate (1.0.1) 35 | cocoapods-downloader (1.1.3) 36 | cocoapods-plugins (1.0.0) 37 | nap 38 | cocoapods-search (1.0.0) 39 | cocoapods-stats (1.0.0) 40 | cocoapods-trunk (1.3.0) 41 | nap (>= 0.8, < 2.0) 42 | netrc (~> 0.11) 43 | cocoapods-try (1.1.0) 44 | colored2 (3.1.2) 45 | concurrent-ruby (1.0.5) 46 | escape (0.0.4) 47 | fourflusher (2.0.1) 48 | fuzzy_match (2.0.4) 49 | gh_inspector (1.0.3) 50 | i18n (0.9.1) 51 | concurrent-ruby (~> 1.0) 52 | minitest (5.10.3) 53 | molinillo (0.5.7) 54 | nanaimo (0.2.3) 55 | nap (1.1.0) 56 | netrc (0.11.0) 57 | ruby-macho (1.1.0) 58 | thread_safe (0.3.6) 59 | tzinfo (1.2.4) 60 | thread_safe (~> 0.1) 61 | xcodeproj (1.5.3) 62 | CFPropertyList (~> 2.3.3) 63 | claide (>= 1.0.2, < 2.0) 64 | colored2 (~> 3.1) 65 | nanaimo (~> 0.2.3) 66 | 67 | PLATFORMS 68 | ruby 69 | 70 | DEPENDENCIES 71 | cocoapods 72 | 73 | BUNDLED WITH 74 | 1.15.4 75 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open Street Maps to react-native 2 | 3 | This project is one fork of [react-native-maps](https://github.com/react-community/react-native-maps) to use open-street-map 4 | 5 | [![npm version](https://img.shields.io/npm/v/react-native-open-street-map.svg?style=flat)](https://www.npmjs.com/package/react-native-open-street-map) 6 | 7 | ## RoadMap 8 | 9 | - [x] change use of GoogleMaps to OpenStreetMap 10 | 11 | - [x] render map in open-street-maps in android 12 | 13 | - [ ] add props OpenStreetMap (WIP) 14 | 15 | - [x] zoom 16 | - [x] router 17 | - [x] router with one location 18 | - [ ] initial router 19 | 20 | - [ ] render open-street-maps to iOS 21 | 22 | 23 | 24 | 25 | ## How to use 26 | 27 | this project is done to render maps in open-street-maps on android 28 | 29 | ## install 30 | 31 | 32 | ``` 33 | npm i react-native-open-street-map 34 | ``` 35 | or 36 | ``` 37 | yarn add react-native-open-street-map 38 | ``` 39 | 40 | ### Android 41 | 42 | `setting.gradle` 43 | 44 | ```gradle 45 | // Open Street Map 46 | include ':react-native-open-street-map' 47 | project(':react-native-open-street-map').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-open-street-map/lib/android') 48 | ``` 49 | 50 | `app/build.gradle` 51 | 52 | ```gradle 53 | 54 | dependencies { 55 | ... 56 | compile (project(':react-native-open-street-map')) { 57 | // if you use the lib gms in the project or libs on project 58 | exclude group: 'com.google.android.gms' 59 | } 60 | ``` 61 | 62 | `app/src/main/java/{project_name}/MainApplication.java` 63 | ```java 64 | 65 | ... 66 | import com.airbnb.android.react.maps.MapsPackage; 67 | 68 | public class MainApplication extends Application implements ReactApplication { 69 | 70 | @Override 71 | protected List getPackages() { 72 | new MainReactPackage(), 73 | new MapsPackage() // insert this line to init module maps 74 | } 75 | } 76 | ``` 77 | 78 | 79 | ### iOS 80 | 81 | the iOS instalation is equals in the lib of react-native-maps because this fork not set iOS to use Open Street Maps, only Apple Maps. 82 | 83 | ## Props 84 | 85 | name | type | iOS | Android | Info 86 | ------ | ---- | ------- | ---- | ---- 87 | router | Object | - | OK | router object espcificate in [routerObject](#router-object) 88 | region | Geolocation | - | OK | the initial region render map 89 | zoom | int | - | OK | show init zoom 90 | showsUserLocation | boolean | - | OK | show location in Map 91 | 92 | ### Router Object 93 | name | type | required | Info 94 | ----- | ----- | ----- | ----- 95 | coordinates | Array | true | array of object with latitude and longitude 96 | titleA | String | true | title of first location 97 | descriptionA | String | true | description of first location 98 | titleB | String | false | title of second location 99 | descriptionB | String | false | description of second location 100 | 101 | 102 | ## Exaple 103 | 104 | ### How to make router from point A to point B 105 | 106 | ```jsx 107 | import React from 'react'; 108 | import { Dimensions } from 'react-native'; 109 | import MapView from 'react-native-open-street-map'; 110 | 111 | class CustonMap extends React.PureComponent { 112 | render() { 113 | const { 114 | width, 115 | height, 116 | } = Dimensions.get('window'); 117 | const region = { 118 | latitude: 0, 119 | longitude: 0, 120 | latitudeDelta: 0.0922, 121 | longitudeDelta: 0.0922 * (width / height) 122 | }; 123 | const latitudes = [-15.806553, -15.8202434]; 124 | const longitudes = [-47.8891454, -47.9045093]; 125 | 126 | return ( 127 | 152 | ); 153 | } 154 | } 155 | 156 | ``` 157 | 158 | 159 | #### sample router with one point object 160 | 161 | ```jsx 162 | import React from 'react'; 163 | import { Dimensions } from 'react-native'; 164 | import MapView from 'react-native-open-street-map'; 165 | 166 | class CustonMap extends React.PureComponent { 167 | render() { 168 | const { 169 | width, 170 | height, 171 | } = Dimensions.get('window'); 172 | const region = { 173 | latitude: 0, 174 | longitude: 0, 175 | latitudeDelta: 0.0922, 176 | longitudeDelta: 0.0922 * (width / height) 177 | }; 178 | return ( 179 | 197 | ); 198 | } 199 | } 200 | ``` 201 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /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.3.2' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | mavenLocal() 15 | jcenter() 16 | maven { 17 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 18 | url "$rootDir/node_modules/react-native/android" 19 | } 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | executorType: docker 3 | jobs: 4 | build: 5 | resource_class: large 6 | environment: 7 | - GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"' 8 | - REACT_NATIVE_MAX_WORKERS: 2 9 | - ANDROID_BUILD_TOOLS_VERSION: "26.0.2" 10 | working_directory: ~/app 11 | docker: 12 | - image: entria/react-native-android:0.1.72 13 | steps: 14 | - checkout 15 | - restore_cache: 16 | keys: 17 | - v1-npm-{{ .Branch }}-{{ checksum "yarn.lock" }} 18 | - v1-npm 19 | - run: 20 | name: Install Dependencies 21 | command: yarn install 22 | - run: 23 | name: Lint 24 | command: yarn lint 25 | - run: 26 | name: Run Checks 27 | command: | 28 | cd android 29 | chmod +x ./gradlew 30 | ./gradlew clean && ./gradlew && ./gradlew check 31 | - save_cache: 32 | key: v1-npm 33 | paths: 34 | - node_modules/ 35 | - save_cache: 36 | key: v1-npm-{{ .Branch }}-{{ checksum "yarn.lock" }} 37 | paths: 38 | - node_modules/ 39 | -------------------------------------------------------------------------------- /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`, `rgba(r,g,b,0.5)` | The stroke color to use for the path. 11 | | `fillColor` | `String` | `#000`, `rgba(r,g,b,0.5)` | 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. Other values : `butt`, `square` 14 | | `lineJoin` | `String` | | The line join style to apply to corners of the path. possible value: `miter`, `round`, `bevel` 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 | npm install 15 | npm run build:ios 16 | npm run run:ios 17 | ``` 18 | 19 | or 20 | 21 | ``` 22 | yarn install 23 | yarn build:ios 24 | yarn run:ios 25 | ``` 26 | 27 | ## android 28 | 29 | 1. Start your emulator 30 | 31 | 2. Install dependencies and run the example: 32 | 33 | ``` 34 | npm install 35 | npm run run:android 36 | ``` 37 | 38 | or 39 | 40 | ``` 41 | yarn install 42 | yarn run:android 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/marker.md: -------------------------------------------------------------------------------- 1 | # `` Component API 2 | 3 | ## Props 4 | 5 | | Prop | Type | Default | Note | 6 | |---|---|---|---| 7 | | `title` | `String` | | The title of the marker. This is only used if the component has no children that are an ``, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided. 8 | | `description` | `String` | | The description of the marker. This is only used if the component has no children that are an ``, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided. 9 | | `image` | `ImageSource` | | A custom image to be used as the marker's icon. Only local image resources are allowed to be used. 10 | | `pinColor` | `Color` | | If no custom marker view or custom image is provided, the platform default pin will be used, which can be customized by this color. Ignored if a custom marker is being used. 11 | | `coordinate` | `LatLng` | | The coordinate for the marker. 12 | | `centerOffset` | `Point` | | The offset (in points) at which to display the view.

By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in points. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.

For Google Maps, see the `anchor` prop. 13 | | `calloutOffset` | `Point` | | The offset (in points) at which to place the callout bubble.

This property determines the additional distance by which to move the callout bubble. When this property is set to (0, 0), the anchor point of the callout bubble is placed on the top-center point of the marker view’s frame. Specifying positive offset values moves the callout bubble down and to the right, while specifying negative values moves it up and to the left.

For android, see the `calloutAnchor` prop. 14 | | `anchor` | `Point` | | Sets the anchor point for the marker.

The anchor specifies the point in the icon image that is anchored to the marker's position on the Earth's surface.

The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner. The anchoring point in a W x H image is the nearest discrete grid point in a (W + 1) x (H + 1) grid, obtained by scaling the then rounding. For example, in a 4 x 2 image, the anchor point (0.7, 0.6) resolves to the grid point at (3, 1).

For MapKit on iOS, see the `centerOffset` prop. 15 | | `calloutAnchor` | `Point` | | Specifies the point in the marker image at which to anchor the callout when it is displayed. This is specified in the same coordinate system as the anchor. See the `anchor` prop for more details.

The default is the top middle of the image.

For ios, see the `calloutOffset` prop. 16 | | `flat` | `Boolean` | | Sets whether this marker should be flat against the map true or a billboard facing the camera false. 17 | | `identifier` | `String` | | An identifier used to reference this marker at a later date. 18 | | `rotation` | `Float` | | A float number indicating marker's rotation angle, in degrees. 19 | | `draggable` | `` | | This is a non-value based prop. Adding this allows the marker to be draggable (re-positioned). 20 | 21 | ## Events 22 | 23 | To access event data, you will need to use `e.nativeEvent`. For example, `onPress={e => console.log(e.nativeEvent)}` will log the entire event object to your console. 24 | 25 | | Event Name | Returns | Notes 26 | |---|---|---| 27 | | `onPress` | `{ coordinate: LatLng, position: Point }` | Callback that is called when the user presses on the marker 28 | | `onSelect` | `{ coordinate: LatLng, position: Point }` | Callback that is called when the user selects the marker, before the callout is shown. **Note**: iOS only. 29 | | `onDeselect` | `{ coordinate: LatLng, position: Point }` | Callback that is called when the marker is deselected, before the callout is hidden. **Note**: iOS only. 30 | | `onCalloutPress` | | Callback that is called when the user taps the callout view. 31 | | `onDragStart` | `{ coordinate: LatLng, position: Point }` | Callback that is called when the user initiates a drag on this marker (if it is draggable) 32 | | `onDrag` | `{ coordinate: LatLng, position: Point }` | Callback called continuously as the marker is dragged 33 | | `onDragEnd` | `{ coordinate: LatLng, position: Point }` | Callback that is called when a drag on this marker finishes. This is usually the point you will want to setState on the marker's coordinate again 34 | 35 | 36 | ## Methods 37 | 38 | | Method Name | Arguments | Notes 39 | |---|---|---| 40 | | `showCallout` | | Shows the callout for this marker 41 | | `hideCallout` | | Hides the callout for this marker 42 | 43 | 44 | 45 | ## Types 46 | 47 | ``` 48 | type LatLng { 49 | latitude: Number, 50 | longitude: Number, 51 | } 52 | ``` 53 | 54 | ``` 55 | type Point { 56 | x: Number, 57 | y: Number, 58 | } 59 | ``` 60 | -------------------------------------------------------------------------------- /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`, `rgba(r,g,b,0.5)` | The stroke color to use for the path. 10 | | `fillColor` | `String` | `#000`, `rgba(r,g,b,0.5)` | 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 | | `tappable` | `Bool` | false (for iOS) | Boolean to allow a polygon to be tappable and use the onPress function. 18 | 19 | ## Events 20 | 21 | | Event Name | Returns | Notes 22 | |---|---|---| 23 | | `onPress` | | Callback that is called when the user presses on the polygon 24 | 25 | ## Types 26 | 27 | ``` 28 | type LatLng { 29 | latitude: Number, 30 | longitude: Number, 31 | } 32 | ``` 33 | -------------------------------------------------------------------------------- /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 | | `strokeColors` | `Array` | `null` | The stroke colors to use for the path (iOS only). Must be the same length as `coordinates`. 11 | | `lineCap` | `String` | `round` | The line cap style to apply to the open ends of the path. Possible values are `butt`, `round` or `square`. 12 | | `lineJoin` | `String` | `round` | The line join style to apply to corners of the path. Possible values are `miter`, `round` or `bevel`. 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 polyline 23 | 24 | ## Types 25 | 26 | ``` 27 | type LatLng { 28 | latitude: Number, 29 | longitude: Number, 30 | } 31 | ``` 32 | 33 | ## Gradient Polylines (iOS MapKit only) 34 | 35 | Gradient polylines can be created by using the `strokeColors` prop. `strokeColors` must be an array with the same number of elements as `coordinates`. 36 | 37 | Example: 38 | 39 | ```js 40 | 41 | 61 | 62 | ``` 63 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/debug.keystore -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/example/rnosm/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.example.rnosm; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 32 | client.addPlugin(new ReactFlipperPlugin()); 33 | client.addPlugin(new DatabasesFlipperPlugin(context)); 34 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 35 | client.addPlugin(CrashReporterPlugin.getInstance()); 36 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 37 | NetworkingModule.setCustomClientBuilder( 38 | new NetworkingModule.CustomClientBuilder() { 39 | @Override 40 | public void apply(OkHttpClient.Builder builder) { 41 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 42 | } 43 | }); 44 | client.addPlugin(networkFlipperPlugin); 45 | client.start(); 46 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 47 | // Hence we run if after all native modules have been initialized 48 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 49 | if (reactContext == null) { 50 | reactInstanceManager.addReactInstanceEventListener( 51 | new ReactInstanceManager.ReactInstanceEventListener() { 52 | @Override 53 | public void onReactContextInitialized(ReactContext reactContext) { 54 | reactInstanceManager.removeReactInstanceEventListener(this); 55 | reactContext.runOnNativeModulesQueueThread( 56 | new Runnable() { 57 | @Override 58 | public void run() { 59 | client.addPlugin(new FrescoFlipperPlugin()); 60 | } 61 | }); 62 | } 63 | }); 64 | } else { 65 | client.addPlugin(new FrescoFlipperPlugin()); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/rnosm/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.rnosm; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "RnOsmExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/rnosm/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.rnosm; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.ReactInstanceManager; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | import com.airbnb.android.react.maps.MapsPackage; 14 | 15 | public class MainApplication extends Application implements ReactApplication { 16 | 17 | private final ReactNativeHost mReactNativeHost = 18 | new ReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | // Packages that cannot be autolinked yet can be added manually here, for RnOsmExample: 29 | // packages.add(new MyReactNativePackage()); 30 | packages.add(new MapsPackage()); 31 | return packages; 32 | } 33 | 34 | @Override 35 | protected String getJSMainModuleName() { 36 | return "index"; 37 | } 38 | }; 39 | 40 | @Override 41 | public ReactNativeHost getReactNativeHost() { 42 | return mReactNativeHost; 43 | } 44 | 45 | @Override 46 | public void onCreate() { 47 | super.onCreate(); 48 | SoLoader.init(this, /* native exopackage */ false); 49 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled 50 | } 51 | 52 | /** 53 | * Loads Flipper in React Native templates. 54 | * 55 | * @param context 56 | */ 57 | private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 58 | if (BuildConfig.DEBUG) { 59 | try { 60 | /* 61 | We use reflection here to pick up the class that initializes Flipper, 62 | since Flipper library is not available in release mode 63 | */ 64 | Class aClass = Class.forName("com.example.rnosm.ReactNativeFlipper"); 65 | aClass 66 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 67 | .invoke(null, context, reactInstanceManager); 68 | } catch (ClassNotFoundException e) { 69 | e.printStackTrace(); 70 | } catch (NoSuchMethodException e) { 71 | e.printStackTrace(); 72 | } catch (IllegalAccessException e) { 73 | e.printStackTrace(); 74 | } catch (InvocationTargetException e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RnOsm Example 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /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 | ext { 5 | minSdkVersion = 16 6 | compileSdkVersion = 29 7 | targetSdkVersion = 29 8 | } 9 | repositories { 10 | google() 11 | mavenCentral() 12 | jcenter() 13 | } 14 | dependencies { 15 | classpath("com.android.tools.build:gradle:3.5.3") 16 | 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | mavenCentral() 36 | jcenter() 37 | maven { url 'https://www.jitpack.io' } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /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 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | FLIPPER_VERSION=0.54.0 23 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'RnOsmExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | 5 | 6 | include ':react-native-open-street-map' 7 | project(':react-native-open-street-map').projectDir = new File(rootProject.projectDir, '../../lib/android') 8 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RnOsmExample", 3 | "displayName": "RnOsm Example" 4 | } 5 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/index.tsx: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src/App'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /example/ios/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // RnOsmExample 4 | // 5 | 6 | import Foundation 7 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'RnOsmExample' do 7 | config = use_native_modules! 8 | 9 | use_react_native!(:path => config["reactNativePath"]) 10 | 11 | pod 'rn-osm', :path => '../..' 12 | 13 | # Enables Flipper. 14 | # 15 | # Note that if you have use_frameworks! enabled, Flipper will not work and 16 | # you should disable these next few lines. 17 | use_flipper!({ 'Flipper' => '0.80.0' }) 18 | post_install do |installer| 19 | flipper_post_install(installer) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample.xcodeproj/xcshareddata/xcschemes/RnOsmExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | 14 | #ifdef FB_SONARKIT_ENABLED 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | static void InitializeFlipper(UIApplication *application) { 22 | FlipperClient *client = [FlipperClient sharedClient]; 23 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 24 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 25 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 26 | [client addPlugin:[FlipperKitReactPlugin new]]; 27 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 28 | [client start]; 29 | } 30 | #endif 31 | 32 | @implementation AppDelegate 33 | 34 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 35 | { 36 | #ifdef FB_SONARKIT_ENABLED 37 | InitializeFlipper(application); 38 | #endif 39 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 40 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 41 | moduleName:@"RnOsmExample" 42 | initialProperties:nil]; 43 | 44 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 45 | 46 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 47 | UIViewController *rootViewController = [UIViewController new]; 48 | rootViewController.view = rootView; 49 | self.window.rootViewController = rootViewController; 50 | [self.window makeKeyAndVisible]; 51 | return YES; 52 | } 53 | 54 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 55 | { 56 | #if DEBUG 57 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 58 | #else 59 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 60 | #endif 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample/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/RnOsmExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | RnOsm Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /example/ios/RnOsmExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const blacklist = require('metro-config/src/defaults/blacklist'); 3 | const escape = require('escape-string-regexp'); 4 | const pak = require('../package.json'); 5 | 6 | const root = path.resolve(__dirname, '..'); 7 | 8 | const modules = Object.keys({ 9 | ...pak.peerDependencies, 10 | }); 11 | 12 | module.exports = { 13 | projectRoot: __dirname, 14 | watchFolders: [root], 15 | 16 | // We need to make sure that only one version is loaded for peerDependencies 17 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 18 | resolver: { 19 | blacklistRE: blacklist( 20 | modules.map( 21 | (m) => 22 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 23 | ) 24 | ), 25 | 26 | extraNodeModules: modules.reduce((acc, name) => { 27 | acc[name] = path.join(__dirname, 'node_modules', name); 28 | return acc; 29 | }, {}), 30 | }, 31 | 32 | transformer: { 33 | getTransformOptions: async () => ({ 34 | transform: { 35 | experimentalImportSupport: false, 36 | inlineRequires: true, 37 | }, 38 | }), 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rn-osm-example", 3 | "description": "Example app for rn-osm", 4 | "version": "0.0.1", 5 | "private": true, 6 | "scripts": { 7 | "android": "react-native run-android", 8 | "ios": "react-native run-ios", 9 | "start": "react-native start" 10 | }, 11 | "dependencies": { 12 | "@babel/plugin-proposal-decorators": "^7.17.9", 13 | "react": "16.13.1", 14 | "react-native": "0.64.1" 15 | }, 16 | "devDependencies": { 17 | "@babel/core": "^7.12.10", 18 | "@babel/runtime": "^7.12.5", 19 | "babel-plugin-module-resolver": "^4.0.0", 20 | "metro-react-native-babel-preset": "^0.64.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { StyleSheet, View, Dimensions } from 'react-native'; 3 | import MapView from 'react-native-open-street-map'; 4 | 5 | export default class CustonMap extends React.PureComponent { 6 | render() { 7 | const { 8 | width, 9 | height, 10 | } = Dimensions.get('window'); 11 | const region = { 12 | latitude: 0, 13 | longitude: 0, 14 | latitudeDelta: 0.0922, 15 | longitudeDelta: 0.0922 * (width / height) 16 | }; 17 | return ( 18 | 36 | ); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon May 08 11:03:28 PDT 2017 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-4.0-all.zip 7 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import MapView from './lib/components/MapView'; 2 | 3 | export default MapView 4 | -------------------------------------------------------------------------------- /lib/android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | react-native-maps-lib 4 | Project react-native-maps-lib created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /lib/android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | #Thu Dec 28 16:10:59 GMT-03:00 2017 2 | connection.project.dir=../.. 3 | -------------------------------------------------------------------------------- /lib/android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.3" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 25 10 | } 11 | 12 | packagingOptions { 13 | exclude 'META-INF/LICENSE' 14 | exclude 'META-INF/DEPENDENCIES.txt' 15 | exclude 'META-INF/LICENSE.txt' 16 | exclude 'META-INF/NOTICE.txt' 17 | exclude 'META-INF/NOTICE' 18 | exclude 'META-INF/DEPENDENCIES' 19 | exclude 'META-INF/notice.txt' 20 | exclude 'META-INF/license.txt' 21 | exclude 'META-INF/dependencies.txt' 22 | exclude 'META-INF/LGPL2.1' 23 | } 24 | 25 | lintOptions { 26 | disable 'InvalidPackage' 27 | } 28 | 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_1_7 31 | targetCompatibility JavaVersion.VERSION_1_7 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation "com.facebook.react:react-native:+" 37 | implementation "com.google.android.gms:play-services-base:10.2.4" 38 | implementation "com.google.android.gms:play-services-maps:10.2.4" 39 | implementation 'org.osmdroid:osmdroid-android:6.1.11' 40 | implementation 'junit:junit:4.12' 41 | } 42 | -------------------------------------------------------------------------------- /lib/android/gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_CODE=4 2 | VERSION_NAME=0.19.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 | -------------------------------------------------------------------------------- /lib/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enieber/react-native-open-street-map/b7f60c62fea3df108a9ef019047e8119a7276386/lib/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 7 | 9 | 11 | 12 | -------------------------------------------------------------------------------- /lib/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.airbnb.android.react.maps.open.OpenAirMapManager; 6 | import com.airbnb.android.react.maps.open.OpenAirMapModule; 7 | import com.airbnb.android.react.maps.open.collout.OpenAirMapCalloutManager; 8 | import com.airbnb.android.react.maps.open.marker.OpenAirMapMarkerManager; 9 | import com.airbnb.android.react.maps.open.polyline.OpenAirMapPolylineManager; 10 | import com.facebook.react.ReactPackage; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | import com.facebook.react.bridge.NativeModule; 13 | import com.facebook.react.bridge.ReactApplicationContext; 14 | import com.facebook.react.uimanager.ViewManager; 15 | 16 | import java.util.Arrays; 17 | import java.util.Collections; 18 | import java.util.List; 19 | 20 | public class MapsPackage implements ReactPackage { 21 | public MapsPackage(Activity activity) { 22 | } // backwards compatibility 23 | 24 | public MapsPackage() { 25 | } 26 | 27 | @Override 28 | public List createNativeModules(ReactApplicationContext reactContext) { 29 | return Arrays.asList(new OpenAirMapModule(reactContext)); 30 | } 31 | @Override 32 | public List createViewManagers(ReactApplicationContext reactContext) { 33 | OpenAirMapCalloutManager calloutManager = new OpenAirMapCalloutManager(); 34 | OpenAirMapMarkerManager annotationManager = new OpenAirMapMarkerManager(); 35 | OpenAirMapPolylineManager polylineManager = new OpenAirMapPolylineManager(reactContext); 36 | OpenAirMapManager mapManager = new OpenAirMapManager(reactContext); 37 | 38 | return Arrays.asList( 39 | calloutManager, 40 | annotationManager, 41 | polylineManager, 42 | mapManager); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/Bounds.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open; 2 | 3 | import org.osmdroid.util.GeoPoint; 4 | 5 | public class Bounds { 6 | private GeoPoint latitude; 7 | private GeoPoint longitude; 8 | 9 | public Bounds(GeoPoint latitude, GeoPoint longitude) { 10 | this.latitude = latitude; 11 | this.longitude = longitude; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/LatLngBoundsUtils.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open; 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 | 8 | public static boolean BoundsAreDifferent(LatLngBounds a, LatLngBounds b) { 9 | LatLng centerA = a.getCenter(); 10 | double latA = centerA.latitude; 11 | double lngA = centerA.longitude; 12 | double latDeltaA = a.northeast.latitude - a.southwest.latitude; 13 | double lngDeltaA = a.northeast.longitude - a.southwest.longitude; 14 | 15 | LatLng centerB = b.getCenter(); 16 | double latB = centerB.latitude; 17 | double lngB = centerB.longitude; 18 | double latDeltaB = b.northeast.latitude - b.southwest.latitude; 19 | double lngDeltaB = b.northeast.longitude - b.southwest.longitude; 20 | 21 | double latEps = LatitudeEpsilon(a, b); 22 | double lngEps = LongitudeEpsilon(a, b); 23 | 24 | return 25 | different(latA, latB, latEps) || 26 | different(lngA, lngB, lngEps) || 27 | different(latDeltaA, latDeltaB, latEps) || 28 | different(lngDeltaA, lngDeltaB, lngEps); 29 | } 30 | 31 | private static boolean different(double a, double b, double epsilon) { 32 | return Math.abs(a - b) > epsilon; 33 | } 34 | 35 | private static double LatitudeEpsilon(LatLngBounds a, LatLngBounds b) { 36 | double sizeA = a.northeast.latitude - a.southwest.latitude; // something mod 180? 37 | double sizeB = b.northeast.latitude - b.southwest.latitude; // something mod 180? 38 | double size = Math.min(Math.abs(sizeA), Math.abs(sizeB)); 39 | return size / 2560; 40 | } 41 | 42 | private static double LongitudeEpsilon(LatLngBounds a, LatLngBounds b) { 43 | double sizeA = a.northeast.longitude - a.southwest.longitude; 44 | double sizeB = b.northeast.longitude - b.southwest.longitude; 45 | double size = Math.min(Math.abs(sizeA), Math.abs(sizeB)); 46 | return size / 2560; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapFeature.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open; 2 | import android.content.Context; 3 | import com.facebook.react.views.view.ReactViewGroup; 4 | import org.osmdroid.views.MapView; 5 | 6 | public abstract class OpenAirMapFeature extends ReactViewGroup { 7 | public OpenAirMapFeature(Context context) { 8 | super(context); 9 | } 10 | 11 | public abstract void addToMap(MapView map); 12 | 13 | public abstract void removeFromMap(MapView map); 14 | 15 | public abstract Object getFeature(); 16 | } 17 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenAirMapModule.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open; 2 | 3 | 4 | import android.app.Activity; 5 | 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 8 | 9 | import java.io.Closeable; 10 | import java.io.IOException; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | public class OpenAirMapModule extends ReactContextBaseJavaModule { 15 | 16 | private static final String SNAPSHOT_RESULT_FILE = "file"; 17 | private static final String SNAPSHOT_RESULT_BASE64 = "base64"; 18 | private static final String SNAPSHOT_FORMAT_PNG = "png"; 19 | private static final String SNAPSHOT_FORMAT_JPG = "jpg"; 20 | 21 | public OpenAirMapModule(ReactApplicationContext reactContext) { 22 | super(reactContext); 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "OpenAirMapModule"; 28 | } 29 | 30 | @Override 31 | public Map getConstants() { 32 | final Map constants = new HashMap<>(); 33 | constants.put("legalNotice", "This license information is displayed in Settings > Google > Open Source on any device running Google Play services."); 34 | return constants; 35 | } 36 | 37 | public Activity getActivity() { 38 | return getCurrentActivity(); 39 | } 40 | 41 | public static void closeQuietly(Closeable closeable) { 42 | if (closeable == null) return; 43 | try { 44 | closeable.close(); 45 | } catch (IOException ignored) { 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/OpenMapPackager.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open; 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 OpenMapPackager implements ReactPackage { 16 | public OpenMapPackager(Activity activity) { 17 | } // backwards compatibility 18 | 19 | public OpenMapPackager() { 20 | } 21 | 22 | @Override 23 | public List createNativeModules(ReactApplicationContext reactContext) { 24 | return Arrays.asList(new OpenAirMapModule(reactContext)); 25 | } 26 | 27 | @Override 28 | public List createViewManagers(ReactApplicationContext reactContext) { 29 | OpenAirMapManager mapManager = new OpenAirMapManager(reactContext); 30 | 31 | return Arrays.asList(mapManager); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/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.open; 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 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/collout/OpenAirMapCallout.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open.collout; 2 | 3 | 4 | import android.content.Context; 5 | 6 | import com.facebook.react.views.view.ReactViewGroup; 7 | 8 | public class OpenAirMapCallout extends ReactViewGroup { 9 | private boolean tooltip = false; 10 | public int width; 11 | public int height; 12 | 13 | public OpenAirMapCallout(Context context) { 14 | super(context); 15 | } 16 | 17 | public void setTooltip(boolean tooltip) { 18 | this.tooltip = tooltip; 19 | } 20 | 21 | public boolean getTooltip() { 22 | return this.tooltip; 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/collout/OpenAirMapCalloutManager.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open.collout; 2 | 3 | import com.airbnb.android.react.maps.open.SizeReportingShadowNode; 4 | import com.facebook.react.common.MapBuilder; 5 | import com.facebook.react.uimanager.LayoutShadowNode; 6 | import com.facebook.react.uimanager.ThemedReactContext; 7 | import com.facebook.react.uimanager.ViewGroupManager; 8 | import com.facebook.react.uimanager.annotations.ReactProp; 9 | 10 | import java.util.Map; 11 | 12 | import javax.annotation.Nullable; 13 | 14 | public class OpenAirMapCalloutManager extends ViewGroupManager { 15 | 16 | @Override 17 | public String getName() { 18 | return "AIRMapCallout"; 19 | } 20 | 21 | @Override 22 | public OpenAirMapCallout createViewInstance(ThemedReactContext context) { 23 | return new OpenAirMapCallout(context); 24 | } 25 | 26 | @ReactProp(name = "tooltip", defaultBoolean = false) 27 | public void setTooltip(OpenAirMapCallout view, boolean tooltip) { 28 | view.setTooltip(tooltip); 29 | } 30 | 31 | @Override 32 | @Nullable 33 | public Map getExportedCustomDirectEventTypeConstants() { 34 | return MapBuilder.of("onPress", MapBuilder.of("registrationName", "onPress")); 35 | } 36 | 37 | @Override 38 | public LayoutShadowNode createShadowNodeInstance() { 39 | // we use a custom shadow node that emits the width/height of the view 40 | // after layout with the updateExtraData method. Without this, we can't generate 41 | // a bitmap of the appropriate width/height of the rendered view. 42 | return new SizeReportingShadowNode(); 43 | } 44 | 45 | @Override 46 | public void updateExtraData(OpenAirMapCallout view, Object extraData) { 47 | // This method is called from the shadow node with the width/height of the rendered 48 | // marker view. 49 | //noinspection unchecked 50 | Map data = (Map) extraData; 51 | float width = data.get("width"); 52 | float height = data.get("height"); 53 | view.width = (int) width; 54 | view.height = (int) height; 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/marker/OpenAirMapMarker.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open.marker; 2 | 3 | import android.content.Context; 4 | 5 | import com.airbnb.android.react.maps.open.OpenAirMapFeature; 6 | 7 | import org.osmdroid.views.MapView; 8 | 9 | class OpenAirMapMarker extends OpenAirMapFeature { 10 | 11 | public OpenAirMapMarker(Context context) { 12 | super(context); 13 | } 14 | 15 | @Override 16 | public void addToMap(MapView map) { 17 | 18 | } 19 | 20 | @Override 21 | public void removeFromMap(MapView map) { 22 | 23 | } 24 | 25 | @Override 26 | public Object getFeature() { 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/marker/OpenAirMapMarkerManager.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open.marker; 2 | 3 | import com.airbnb.android.react.maps.open.SizeReportingShadowNode; 4 | import com.facebook.react.bridge.ReadableArray; 5 | import com.facebook.react.bridge.ReadableMap; 6 | import com.facebook.react.common.MapBuilder; 7 | import com.facebook.react.uimanager.LayoutShadowNode; 8 | import com.facebook.react.uimanager.ThemedReactContext; 9 | import com.facebook.react.uimanager.ViewGroupManager; 10 | import com.facebook.react.uimanager.annotations.ReactProp; 11 | import com.google.android.gms.maps.model.Marker; 12 | 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | import javax.annotation.Nullable; 17 | 18 | public class OpenAirMapMarkerManager extends ViewGroupManager { 19 | 20 | private static final int SHOW_INFO_WINDOW = 1; 21 | private static final int HIDE_INFO_WINDOW = 2; 22 | 23 | public OpenAirMapMarkerManager() { 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return "AIRMapMarker"; 29 | } 30 | 31 | @Override 32 | public OpenAirMapMarker createViewInstance(ThemedReactContext context) { 33 | return new OpenAirMapMarker(context); 34 | } 35 | 36 | @ReactProp(name = "anchor") 37 | public void setAnchor(OpenAirMapMarker view, ReadableMap map) { 38 | // should default to (0.5, 1) (bottom middle) 39 | double x = map != null && map.hasKey("x") ? map.getDouble("x") : 0.5; 40 | double y = map != null && map.hasKey("y") ? map.getDouble("y") : 1.0; 41 | float xFloat = (float)x; 42 | float yFloat = (float)y; 43 | 44 | view.setY(yFloat); 45 | view.setX(xFloat); 46 | } 47 | 48 | @ReactProp(name = "calloutAnchor") 49 | public void setCalloutAnchor(OpenAirMapMarker view, ReadableMap map) { 50 | // should default to (0.5, 0) (top middle) 51 | double x = map != null && map.hasKey("x") ? map.getDouble("x") : 0.5; 52 | double y = map != null && map.hasKey("y") ? map.getDouble("y") : 0.0; 53 | float xFloat = (float)x; 54 | float yFloat = (float)y; 55 | 56 | view.setY(yFloat); 57 | view.setX(xFloat); 58 | } 59 | 60 | @ReactProp(name = "rotation", defaultFloat = 0.0f) 61 | public void setMarkerRotation(OpenAirMapMarker view, float rotation) { 62 | view.setRotation(rotation); 63 | } 64 | 65 | @ReactProp(name = "draggable", defaultBoolean = false) 66 | public void setDraggable(OpenAirMapMarker view, boolean draggable) { 67 | view.setEnabled(draggable); 68 | } 69 | 70 | @Override 71 | @Nullable 72 | public Map getCommandsMap() { 73 | return MapBuilder.of( 74 | "showCallout", SHOW_INFO_WINDOW, 75 | "hideCallout", HIDE_INFO_WINDOW 76 | ); 77 | } 78 | 79 | @Override 80 | public void receiveCommand(OpenAirMapMarker view, int commandId, @Nullable ReadableArray args) { 81 | switch (commandId) { 82 | case SHOW_INFO_WINDOW: 83 | ((Marker) view.getFeature()).showInfoWindow(); 84 | break; 85 | 86 | case HIDE_INFO_WINDOW: 87 | ((Marker) view.getFeature()).hideInfoWindow(); 88 | break; 89 | } 90 | } 91 | 92 | @Override 93 | @Nullable 94 | public Map getExportedCustomDirectEventTypeConstants() { 95 | Map> map = MapBuilder.of( 96 | "onPress", MapBuilder.of("registrationName", "onPress"), 97 | "onCalloutPress", MapBuilder.of("registrationName", "onCalloutPress"), 98 | "onDragStart", MapBuilder.of("registrationName", "onDragStart"), 99 | "onDrag", MapBuilder.of("registrationName", "onDrag"), 100 | "onDragEnd", MapBuilder.of("registrationName", "onDragEnd") 101 | ); 102 | 103 | map.putAll(MapBuilder.of( 104 | "onDragStart", MapBuilder.of("registrationName", "onDragStart"), 105 | "onDrag", MapBuilder.of("registrationName", "onDrag"), 106 | "onDragEnd", MapBuilder.of("registrationName", "onDragEnd") 107 | )); 108 | 109 | return map; 110 | } 111 | 112 | @Override 113 | public LayoutShadowNode createShadowNodeInstance() { 114 | // we use a custom shadow node that emits the width/height of the view 115 | // after layout with the updateExtraData method. Without this, we can't generate 116 | // a bitmap of the appropriate width/height of the rendered view. 117 | return new SizeReportingShadowNode(); 118 | } 119 | 120 | @Override 121 | public void updateExtraData(OpenAirMapMarker view, Object extraData) { 122 | // This method is called from the shadow node with the width/height of the rendered 123 | // marker view. 124 | HashMap data = (HashMap) extraData; 125 | float width = data.get("width"); 126 | float height = data.get("height"); 127 | 128 | // view.update((int) width, (int) height); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/polyline/OpenAirMapPolyline.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open.polyline; 2 | 3 | import android.content.Context; 4 | 5 | import com.airbnb.android.react.maps.open.OpenAirMapFeature; 6 | import com.facebook.react.bridge.ReadableArray; 7 | import com.facebook.react.bridge.ReadableMap; 8 | 9 | import org.osmdroid.util.GeoPoint; 10 | import org.osmdroid.views.MapView; 11 | import org.osmdroid.views.overlay.Polyline; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class OpenAirMapPolyline extends OpenAirMapFeature { 17 | private Polyline polyline; 18 | private MapView map; 19 | private List coordinates = new ArrayList<>(); 20 | private int color; 21 | private float width; 22 | private boolean geodesic; 23 | private float zIndex; 24 | 25 | public OpenAirMapPolyline(Context context) { 26 | super(context); 27 | } 28 | 29 | @Override 30 | public void addToMap(MapView map) { 31 | this.map = map; 32 | } 33 | 34 | @Override 35 | public void removeFromMap(MapView map) { 36 | 37 | } 38 | 39 | public void setCoordinates(ReadableArray coordinates) { 40 | this.coordinates = new ArrayList<>(coordinates.size()); 41 | for (int i = 0; i < coordinates.size(); i++) { 42 | ReadableMap coordinate = coordinates.getMap(i); 43 | this.coordinates.add(i, 44 | new GeoPoint(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"))); 45 | } 46 | if (polyline != null) { 47 | polyline.setPoints(this.coordinates); 48 | } 49 | } 50 | 51 | public void setColor(int color) { 52 | this.color = color; 53 | if (polyline != null) { 54 | polyline.setColor(color); 55 | } 56 | } 57 | 58 | public void setWidth(float width) { 59 | this.width = width; 60 | if (polyline != null) { 61 | polyline.setWidth(width); 62 | } 63 | } 64 | 65 | public void setGeodesic(boolean geodesic) { 66 | this.geodesic = geodesic; 67 | if (polyline != null) { 68 | polyline.setGeodesic(geodesic); 69 | } 70 | } 71 | 72 | @Override 73 | public Object getFeature() { 74 | return polyline; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /lib/android/src/main/java/com/airbnb/android/react/maps/open/polyline/OpenAirMapPolylineManager.java: -------------------------------------------------------------------------------- 1 | package com.airbnb.android.react.maps.open.polyline; 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.Map; 17 | 18 | import javax.annotation.Nullable; 19 | 20 | public class OpenAirMapPolylineManager extends ViewGroupManager { 21 | private final DisplayMetrics metrics; 22 | 23 | public OpenAirMapPolylineManager(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 OpenAirMapPolyline createViewInstance(ThemedReactContext context) { 42 | return new OpenAirMapPolyline(context); 43 | } 44 | 45 | @ReactProp(name = "coordinates") 46 | public void setCoordinate(OpenAirMapPolyline view, ReadableArray coordinates) { 47 | view.setCoordinates(coordinates); 48 | } 49 | 50 | @ReactProp(name = "strokeWidth", defaultFloat = 1f) 51 | public void setStrokeWidth(OpenAirMapPolyline 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(OpenAirMapPolyline view, int color) { 58 | view.setColor(color); 59 | } 60 | 61 | @ReactProp(name = "geodesic", defaultBoolean = false) 62 | public void setGeodesic(OpenAirMapPolyline view, boolean geodesic) { 63 | view.setGeodesic(geodesic); 64 | } 65 | 66 | @Override 67 | @Nullable 68 | public Map getExportedCustomDirectEventTypeConstants() { 69 | return MapBuilder.of( 70 | "onPress", MapBuilder.of("registrationName", "onPress") 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #1a12d1 4 | -------------------------------------------------------------------------------- /lib/components/MapPolygon.js: -------------------------------------------------------------------------------- 1 | import PropTypes from 'prop-types'; 2 | import React from 'react'; 3 | import { 4 | ViewPropTypes, 5 | View, 6 | } from 'react-native'; 7 | import decorateMapComponent, { 8 | USES_DEFAULT_IMPLEMENTATION, 9 | SUPPORTED, 10 | } from './decorateMapComponent'; 11 | 12 | // if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44) 13 | const viewPropTypes = ViewPropTypes || View.propTypes; 14 | 15 | const propTypes = { 16 | ...viewPropTypes, 17 | 18 | /** 19 | * An array of coordinates to describe the polygon 20 | */ 21 | coordinates: PropTypes.arrayOf(PropTypes.shape({ 22 | /** 23 | * Latitude/Longitude coordinates 24 | */ 25 | latitude: PropTypes.number.isRequired, 26 | longitude: PropTypes.number.isRequired, 27 | })), 28 | 29 | /** 30 | * An array of array of coordinates to describe the polygon holes 31 | */ 32 | holes: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.shape({ 33 | /** 34 | * Latitude/Longitude coordinates 35 | */ 36 | latitude: PropTypes.number.isRequired, 37 | longitude: PropTypes.number.isRequired, 38 | }))), 39 | 40 | /** 41 | * Callback that is called when the user presses on the polygon 42 | */ 43 | onPress: PropTypes.func, 44 | 45 | /** 46 | * Boolean to allow a polygon to be tappable and use the 47 | * onPress function 48 | */ 49 | tappable: PropTypes.bool, 50 | 51 | /** 52 | * The stroke width to use for the path. 53 | */ 54 | strokeWidth: PropTypes.number, 55 | 56 | /** 57 | * The stroke color to use for the path. 58 | */ 59 | strokeColor: PropTypes.string, 60 | 61 | /** 62 | * The fill color to use for the path. 63 | */ 64 | fillColor: PropTypes.string, 65 | 66 | /** 67 | * The order in which this tile overlay is drawn with respect to other overlays. An overlay 68 | * with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays 69 | * with the same z-index is arbitrary. The default zIndex is 0. 70 | * 71 | * @platform android 72 | */ 73 | zIndex: PropTypes.number, 74 | 75 | /** 76 | * The line cap style to apply to the open ends of the path. 77 | * The default style is `round`. 78 | * 79 | * @platform ios 80 | */ 81 | lineCap: PropTypes.oneOf([ 82 | 'butt', 83 | 'round', 84 | 'square', 85 | ]), 86 | 87 | /** 88 | * The line join style to apply to corners of the path. 89 | * The default style is `round`. 90 | * 91 | * @platform ios 92 | */ 93 | lineJoin: PropTypes.oneOf([ 94 | 'miter', 95 | 'round', 96 | 'bevel', 97 | ]), 98 | 99 | /** 100 | * The limiting value that helps avoid spikes at junctions between connected line segments. 101 | * The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If 102 | * the ratio of the miter length—that is, the diagonal length of the miter join—to the line 103 | * thickness exceeds the miter limit, the joint is converted to a bevel join. The default 104 | * miter limit is 10, which results in the conversion of miters whose angle at the joint 105 | * is less than 11 degrees. 106 | * 107 | * @platform ios 108 | */ 109 | miterLimit: PropTypes.number, 110 | 111 | /** 112 | * Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to 113 | * straight lines on the Mercator projection. A geodesic is the shortest path between two 114 | * points on the Earth's surface. The geodesic curve is constructed assuming the Earth is 115 | * a sphere. 116 | * 117 | */ 118 | geodesic: PropTypes.bool, 119 | 120 | /** 121 | * The offset (in points) at which to start drawing the dash pattern. 122 | * 123 | * Use this property to start drawing a dashed line partway through a segment or gap. For 124 | * example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the 125 | * middle of the first gap. 126 | * 127 | * The default value of this property is 0. 128 | * 129 | * @platform ios 130 | */ 131 | lineDashPhase: PropTypes.number, 132 | 133 | /** 134 | * An array of numbers specifying the dash pattern to use for the path. 135 | * 136 | * The array contains one or more numbers that indicate the lengths (measured in points) of the 137 | * line segments and gaps in the pattern. The values in the array alternate, starting with the 138 | * first line segment length, followed by the first gap length, followed by the second line 139 | * segment length, and so on. 140 | * 141 | * This property is set to `null` by default, which indicates no line dash pattern. 142 | * 143 | * @platform ios 144 | */ 145 | lineDashPattern: PropTypes.arrayOf(PropTypes.number), 146 | }; 147 | 148 | const defaultProps = { 149 | strokeColor: '#000', 150 | strokeWidth: 1, 151 | }; 152 | 153 | class MapPolygon extends React.Component { 154 | setNativeProps(props) { 155 | this.polygon.setNativeProps(props); 156 | } 157 | 158 | render() { 159 | const AIRMapPolygon = this.getAirComponent(); 160 | return ( 161 | { this.polygon = ref; }} /> 162 | ); 163 | } 164 | } 165 | 166 | MapPolygon.propTypes = propTypes; 167 | MapPolygon.defaultProps = defaultProps; 168 | 169 | export default decorateMapComponent(MapPolygon, { 170 | componentType: 'Polygon', 171 | providers: { 172 | google: { 173 | ios: SUPPORTED, 174 | android: USES_DEFAULT_IMPLEMENTATION, 175 | }, 176 | }, 177 | }); 178 | -------------------------------------------------------------------------------- /lib/components/MapPolyline.js: -------------------------------------------------------------------------------- 1 | import PropTypes from "prop-types"; 2 | import React from "react"; 3 | import { ViewPropTypes, View } from "react-native"; 4 | import decorateMapComponent, { 5 | USES_DEFAULT_IMPLEMENTATION, 6 | SUPPORTED, 7 | } from "./decorateMapComponent"; 8 | 9 | // if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44) 10 | const viewPropTypes = ViewPropTypes || View.propTypes; 11 | 12 | const propTypes = { 13 | ...viewPropTypes, 14 | 15 | /** 16 | * An array of coordinates to describe the polygon 17 | */ 18 | coordinates: PropTypes.arrayOf( 19 | PropTypes.shape({ 20 | /** 21 | * Latitude/Longitude coordinates 22 | */ 23 | latitude: PropTypes.number.isRequired, 24 | longitude: PropTypes.number.isRequired, 25 | }) 26 | ), 27 | 28 | /** 29 | * Callback that is called when the user presses on the polyline 30 | */ 31 | onPress: PropTypes.func, 32 | 33 | /* Boolean to allow a polyline to be tappable and use the 34 | * onPress function 35 | */ 36 | tappable: PropTypes.bool, 37 | 38 | /** 39 | * The fill color to use for the path. 40 | */ 41 | fillColor: PropTypes.string, 42 | 43 | /** 44 | * The stroke width to use for the path. 45 | */ 46 | strokeWidth: PropTypes.number, 47 | 48 | /** 49 | * The stroke color to use for the path. 50 | */ 51 | strokeColor: PropTypes.string, 52 | 53 | /** 54 | * The stroke colors to use for the path. 55 | */ 56 | strokeColors: PropTypes.arrayOf(PropTypes.string), 57 | 58 | /** 59 | * The order in which this tile overlay is drawn with respect to other overlays. An overlay 60 | * with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays 61 | * with the same z-index is arbitrary. The default zIndex is 0. 62 | * 63 | * @platform android 64 | */ 65 | zIndex: PropTypes.number, 66 | 67 | /** 68 | * The line cap style to apply to the open ends of the path. 69 | * The default style is `round`. 70 | * 71 | * @platform ios 72 | */ 73 | lineCap: PropTypes.oneOf(["butt", "round", "square"]), 74 | 75 | /** 76 | * The line join style to apply to corners of the path. 77 | * The default style is `round`. 78 | * 79 | * @platform ios 80 | */ 81 | lineJoin: PropTypes.oneOf(["miter", "round", "bevel"]), 82 | 83 | /** 84 | * The limiting value that helps avoid spikes at junctions between connected line segments. 85 | * The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If 86 | * the ratio of the miter length—that is, the diagonal length of the miter join—to the line 87 | * thickness exceeds the miter limit, the joint is converted to a bevel join. The default 88 | * miter limit is 10, which results in the conversion of miters whose angle at the joint 89 | * is less than 11 degrees. 90 | * 91 | * @platform ios 92 | */ 93 | miterLimit: PropTypes.number, 94 | 95 | /** 96 | * Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to 97 | * straight lines on the Mercator projection. A geodesic is the shortest path between two 98 | * points on the Earth's surface. The geodesic curve is constructed assuming the Earth is 99 | * a sphere. 100 | * 101 | * @platform android 102 | */ 103 | geodesic: PropTypes.bool, 104 | 105 | /** 106 | * The offset (in points) at which to start drawing the dash pattern. 107 | * 108 | * Use this property to start drawing a dashed line partway through a segment or gap. For 109 | * example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the 110 | * middle of the first gap. 111 | * 112 | * The default value of this property is 0. 113 | * 114 | * @platform ios 115 | */ 116 | lineDashPhase: PropTypes.number, 117 | 118 | /** 119 | * An array of numbers specifying the dash pattern to use for the path. 120 | * 121 | * The array contains one or more numbers that indicate the lengths (measured in points) of the 122 | * line segments and gaps in the pattern. The values in the array alternate, starting with the 123 | * first line segment length, followed by the first gap length, followed by the second line 124 | * segment length, and so on. 125 | * 126 | * This property is set to `null` by default, which indicates no line dash pattern. 127 | * 128 | * @platform ios 129 | */ 130 | lineDashPattern: PropTypes.arrayOf(PropTypes.number), 131 | }; 132 | 133 | const defaultProps = { 134 | strokeColor: "#000", 135 | strokeWidth: 1, 136 | lineJoin: "round", 137 | lineCap: "round", 138 | }; 139 | 140 | class MapPolyline extends React.Component { 141 | setNativeProps(props) { 142 | this.polyline.setNativeProps(props); 143 | } 144 | 145 | render() { 146 | const AIRMapPolyline = this.getAirComponent(); 147 | return ( 148 | { 151 | this.polyline = ref; 152 | }} 153 | /> 154 | ); 155 | } 156 | } 157 | 158 | MapPolyline.propTypes = propTypes; 159 | MapPolyline.defaultProps = defaultProps; 160 | 161 | export default decorateMapComponent(MapPolyline, { 162 | componentType: "Polyline", 163 | providers: { 164 | google: { 165 | ios: SUPPORTED, 166 | android: USES_DEFAULT_IMPLEMENTATION, 167 | }, 168 | }, 169 | }); 170 | -------------------------------------------------------------------------------- /lib/components/ProviderConstants.js: -------------------------------------------------------------------------------- 1 | export const PROVIDER_DEFAULT = 'open-street-map'; 2 | export const PROVIDER_GOOGLE = 'google'; 3 | -------------------------------------------------------------------------------- /lib/components/decorateMapComponent.js: -------------------------------------------------------------------------------- 1 | import PropTypes from 'prop-types'; 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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/ios/AirGoogleMaps/AIRGMSPolygon.h: -------------------------------------------------------------------------------- 1 | // 2 | // AIRGMSPolygon.h 3 | // AirMaps 4 | // 5 | // Created by Gerardo Pacheco 02/05/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @class AIRGoogleMapPolygon; 12 | 13 | @interface AIRGMSPolygon : GMSPolygon 14 | @property (nonatomic, strong) NSString *identifier; 15 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 16 | @end 17 | -------------------------------------------------------------------------------- /lib/ios/AirGoogleMaps/AIRGMSPolygon.m: -------------------------------------------------------------------------------- 1 | // 2 | // AIRGMSPolygon.m 3 | // AirMaps 4 | // 5 | // Created by Gerardo Pacheco 02/05/2017. 6 | // 7 | 8 | #import "AIRGMSPolygon.h" 9 | 10 | @implementation AIRGMSPolygon 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /lib/ios/AirGoogleMaps/AIRGMSPolyline.h: -------------------------------------------------------------------------------- 1 | // 2 | // AIRGMSPolyline.h 3 | // AirMaps 4 | // 5 | // Created by Guilherme Pontes 04/05/2017. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @class AIRGoogleMapPolyline; 12 | 13 | @interface AIRGMSPolyline : GMSPolyline 14 | @property (nonatomic, strong) NSString *identifier; 15 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 16 | @end 17 | -------------------------------------------------------------------------------- /lib/ios/AirGoogleMaps/AIRGMSPolyline.m: -------------------------------------------------------------------------------- 1 | // 2 | // AIRGMSPolyline.m 3 | // AirMaps 4 | // 5 | // Created by Guilherme Pontes 04/05/2017. 6 | // 7 | 8 | #import "AIRGMSPolyline.h" 9 | 10 | @implementation AIRGMSPolyline 11 | @end 12 | -------------------------------------------------------------------------------- /lib/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 "AIRGMSMarker.h" 13 | #import "RCTConvert+AirMap.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, assign) UIEdgeInsets mapPadding; 22 | @property (nonatomic, copy) RCTBubblingEventBlock onMapReady; 23 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 24 | @property (nonatomic, copy) RCTBubblingEventBlock onLongPress; 25 | @property (nonatomic, copy) RCTBubblingEventBlock onMarkerPress; 26 | @property (nonatomic, copy) RCTBubblingEventBlock onChange; 27 | @property (nonatomic, copy) RCTDirectEventBlock onRegionChange; 28 | @property (nonatomic, copy) RCTDirectEventBlock onRegionChangeComplete; 29 | @property (nonatomic, strong) NSMutableArray *markers; 30 | @property (nonatomic, strong) NSMutableArray *polygons; 31 | @property (nonatomic, strong) NSMutableArray *polylines; 32 | @property (nonatomic, strong) NSMutableArray *circles; 33 | @property (nonatomic, strong) NSMutableArray *tiles; 34 | 35 | @property (nonatomic, assign) BOOL showsBuildings; 36 | @property (nonatomic, assign) BOOL showsTraffic; 37 | @property (nonatomic, assign) BOOL showsCompass; 38 | @property (nonatomic, assign) BOOL scrollEnabled; 39 | @property (nonatomic, assign) BOOL zoomEnabled; 40 | @property (nonatomic, assign) BOOL rotateEnabled; 41 | @property (nonatomic, assign) BOOL pitchEnabled; 42 | @property (nonatomic, assign) BOOL showsUserLocation; 43 | @property (nonatomic, assign) BOOL showsMyLocationButton; 44 | @property (nonatomic, assign) BOOL showsIndoorLevelPicker; 45 | 46 | - (void)didPrepareMap; 47 | - (BOOL)didTapMarker:(GMSMarker *)marker; 48 | - (void)didTapPolyline:(GMSPolyline *)polyline; 49 | - (void)didTapPolygon:(GMSPolygon *)polygon; 50 | - (void)didTapAtCoordinate:(CLLocationCoordinate2D)coordinate; 51 | - (void)didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate; 52 | - (void)didChangeCameraPosition:(GMSCameraPosition *)position; 53 | - (void)idleAtCameraPosition:(GMSCameraPosition *)position; 54 | 55 | + (MKCoordinateRegion)makeGMSCameraPositionFromMap:(GMSMapView *)map andGMSCameraPosition:(GMSCameraPosition *)position; 56 | + (GMSCameraPosition*)makeGMSCameraPositionFromMap:(GMSMapView *)map andMKCoordinateRegion:(MKCoordinateRegion)region; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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, assign) CLLocationDegrees rotation; 21 | @property (nonatomic, strong) AIRGMSMarker* realMarker; 22 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 23 | @property (nonatomic, copy) RCTDirectEventBlock onDragStart; 24 | @property (nonatomic, copy) RCTDirectEventBlock onDrag; 25 | @property (nonatomic, copy) RCTDirectEventBlock onDragEnd; 26 | @property (nonatomic, copy) NSString *imageSrc; 27 | @property (nonatomic, copy) NSString *title; 28 | @property (nonatomic, copy) NSString *subtitle; 29 | @property (nonatomic, strong) UIColor *pinColor; 30 | @property (nonatomic, assign) CGPoint anchor; 31 | @property (nonatomic, assign) NSInteger zIndex; 32 | @property (nonatomic, assign) double opacity; 33 | @property (nonatomic, assign) BOOL draggable; 34 | @property (nonatomic, assign) BOOL tracksViewChanges; 35 | 36 | - (void)showCalloutView; 37 | - (void)hideCalloutView; 38 | - (UIView *)markerInfoContents; 39 | - (UIView *)markerInfoWindow; 40 | - (void)didTapInfoWindowOfMarker:(AIRGMSMarker *)marker; 41 | - (void)didBeginDraggingMarker:(AIRGMSMarker *)marker; 42 | - (void)didEndDraggingMarker:(AIRGMSMarker *)marker; 43 | - (void)didDragMarker:(AIRGMSMarker *)marker; 44 | @end 45 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 "RCTConvert+AirMap.h" 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(rotation, CLLocationDegrees) 32 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) 33 | RCT_REMAP_VIEW_PROPERTY(image, imageSrc, NSString) 34 | RCT_EXPORT_VIEW_PROPERTY(title, NSString) 35 | RCT_REMAP_VIEW_PROPERTY(description, subtitle, NSString) 36 | RCT_EXPORT_VIEW_PROPERTY(pinColor, UIColor) 37 | RCT_EXPORT_VIEW_PROPERTY(anchor, CGPoint) 38 | RCT_EXPORT_VIEW_PROPERTY(zIndex, NSInteger) 39 | RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL) 40 | RCT_EXPORT_VIEW_PROPERTY(tracksViewChanges, BOOL) 41 | RCT_EXPORT_VIEW_PROPERTY(opacity, double) 42 | RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTDirectEventBlock) 43 | RCT_EXPORT_VIEW_PROPERTY(onDrag, RCTDirectEventBlock) 44 | RCT_EXPORT_VIEW_PROPERTY(onDragEnd, RCTDirectEventBlock) 45 | 46 | RCT_EXPORT_METHOD(showCallout:(nonnull NSNumber *)reactTag) 47 | { 48 | [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { 49 | id view = viewRegistry[reactTag]; 50 | if (![view isKindOfClass:[AIRGoogleMapMarker class]]) { 51 | RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view); 52 | } else { 53 | [(AIRGoogleMapMarker *) view showCalloutView]; 54 | } 55 | }]; 56 | } 57 | 58 | RCT_EXPORT_METHOD(hideCallout:(nonnull NSNumber *)reactTag) 59 | { 60 | [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { 61 | id view = viewRegistry[reactTag]; 62 | if (![view isKindOfClass:[AIRGoogleMapMarker class]]) { 63 | RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view); 64 | } else { 65 | [(AIRGoogleMapMarker *) view hideCalloutView]; 66 | } 67 | }]; 68 | } 69 | @end 70 | -------------------------------------------------------------------------------- /lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.h: -------------------------------------------------------------------------------- 1 | // 2 | // AIRGoogleMapPolygon.h 3 | // 4 | // Created by Nick Italiano on 10/22/16. 5 | // 6 | 7 | #import 8 | #import 9 | #import "AIRGMSPolygon.h" 10 | #import "AIRMapCoordinate.h" 11 | 12 | @interface AIRGoogleMapPolygon : UIView 13 | 14 | @property (nonatomic, weak) RCTBridge *bridge; 15 | @property (nonatomic, strong) NSString *identifier; 16 | @property (nonatomic, strong) AIRGMSPolygon *polygon; 17 | @property (nonatomic, strong) NSArray *coordinates; 18 | @property (nonatomic, strong) NSArray *> *holes; 19 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 20 | 21 | @property (nonatomic, assign) UIColor *fillColor; 22 | @property (nonatomic, assign) double strokeWidth; 23 | @property (nonatomic, assign) UIColor *strokeColor; 24 | @property (nonatomic, assign) BOOL geodesic; 25 | @property (nonatomic, assign) int zIndex; 26 | @property (nonatomic, assign) BOOL tappable; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /lib/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 "AIRGMSPolygon.h" 9 | #import 10 | 11 | @implementation AIRGoogleMapPolygon 12 | 13 | - (instancetype)init 14 | { 15 | if (self = [super init]) { 16 | _polygon = [[AIRGMSPolygon alloc] init]; 17 | } 18 | 19 | return self; 20 | } 21 | 22 | - (void)setCoordinates:(NSArray *)coordinates 23 | { 24 | _coordinates = coordinates; 25 | 26 | GMSMutablePath *path = [GMSMutablePath path]; 27 | for(int i = 0; i < coordinates.count; i++) 28 | { 29 | [path addCoordinate:coordinates[i].coordinate]; 30 | } 31 | 32 | _polygon.path = path; 33 | } 34 | 35 | - (void)setHoles:(NSArray *> *)holes 36 | { 37 | _holes = holes; 38 | 39 | if (holes.count) 40 | { 41 | NSMutableArray *interiorPolygons = [NSMutableArray array]; 42 | for(int h = 0; h < holes.count; h++) 43 | { 44 | GMSMutablePath *path = [GMSMutablePath path]; 45 | for(int i = 0; i < holes[h].count; i++) 46 | { 47 | [path addCoordinate:holes[h][i].coordinate]; 48 | } 49 | [interiorPolygons addObject:path]; 50 | } 51 | 52 | _polygon.holes = interiorPolygons; 53 | } 54 | } 55 | 56 | -(void)setFillColor:(UIColor *)fillColor 57 | { 58 | _fillColor = fillColor; 59 | _polygon.fillColor = fillColor; 60 | } 61 | 62 | -(void)setStrokeWidth:(double)strokeWidth 63 | { 64 | _strokeWidth = strokeWidth; 65 | _polygon.strokeWidth = strokeWidth; 66 | } 67 | 68 | -(void)setStrokeColor:(UIColor *) strokeColor 69 | { 70 | _strokeColor = strokeColor; 71 | _polygon.strokeColor = strokeColor; 72 | } 73 | 74 | -(void)setGeodesic:(BOOL)geodesic 75 | { 76 | _geodesic = geodesic; 77 | _polygon.geodesic = geodesic; 78 | } 79 | 80 | -(void)setZIndex:(int)zIndex 81 | { 82 | _zIndex = zIndex; 83 | _polygon.zIndex = zIndex; 84 | } 85 | 86 | -(void)setTappable:(BOOL)tappable 87 | { 88 | _tappable = tappable; 89 | _polygon.tappable = tappable; 90 | } 91 | 92 | - (void)setOnPress:(RCTBubblingEventBlock)onPress { 93 | _polygon.onPress = onPress; 94 | } 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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+AirMap.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 | polygon.bridge = self.bridge; 29 | return polygon; 30 | } 31 | 32 | RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRMapCoordinateArray) 33 | RCT_EXPORT_VIEW_PROPERTY(holes, AIRMapCoordinateArrayArray) 34 | RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor) 35 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, double) 36 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor) 37 | RCT_EXPORT_VIEW_PROPERTY(geodesic, BOOL) 38 | RCT_EXPORT_VIEW_PROPERTY(zIndex, int) 39 | RCT_EXPORT_VIEW_PROPERTY(tappable, BOOL) 40 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /lib/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 9 | #import "AIRGMSPolyline.h" 10 | #import "AIRMapCoordinate.h" 11 | #import "AIRGoogleMapMarker.h" 12 | 13 | @interface AIRGoogleMapPolyline : UIView 14 | 15 | @property (nonatomic, weak) RCTBridge *bridge; 16 | @property (nonatomic, strong) NSString *identifier; 17 | @property (nonatomic, strong) AIRGMSPolyline *polyline; 18 | @property (nonatomic, strong) NSArray *coordinates; 19 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 20 | 21 | @property (nonatomic, strong) UIColor *strokeColor; 22 | @property (nonatomic, assign) double strokeWidth; 23 | @property (nonatomic, assign) UIColor *fillColor; 24 | @property (nonatomic, assign) BOOL geodesic; 25 | @property (nonatomic, assign) NSString *title; 26 | @property (nonatomic, assign) int zIndex; 27 | @property (nonatomic, assign) BOOL tappable; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /lib/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 "AIRGMSPolyline.h" 9 | #import "AIRMapCoordinate.h" 10 | #import "AIRGoogleMapMarker.h" 11 | #import "AIRGoogleMapMarkerManager.h" 12 | #import 13 | #import 14 | 15 | @implementation AIRGoogleMapPolyline 16 | 17 | - (instancetype)init 18 | { 19 | if (self = [super init]) { 20 | _polyline = [[AIRGMSPolyline alloc] init]; 21 | } 22 | return self; 23 | } 24 | 25 | -(void)setCoordinates:(NSArray *)coordinates 26 | { 27 | _coordinates = coordinates; 28 | 29 | GMSMutablePath *path = [GMSMutablePath path]; 30 | for(int i = 0; i < coordinates.count; i++) 31 | { 32 | [path addCoordinate:coordinates[i].coordinate]; 33 | } 34 | 35 | _polyline.path = path; 36 | } 37 | 38 | -(void)setStrokeColor:(UIColor *)strokeColor 39 | { 40 | _strokeColor = strokeColor; 41 | _polyline.strokeColor = strokeColor; 42 | } 43 | 44 | -(void)setStrokeWidth:(double)strokeWidth 45 | { 46 | _strokeWidth = strokeWidth; 47 | _polyline.strokeWidth = strokeWidth; 48 | } 49 | 50 | -(void)setFillColor:(UIColor *)fillColor 51 | { 52 | _fillColor = fillColor; 53 | _polyline.spans = @[[GMSStyleSpan spanWithColor:fillColor]]; 54 | } 55 | 56 | -(void)setGeodesic:(BOOL)geodesic 57 | { 58 | _geodesic = geodesic; 59 | _polyline.geodesic = geodesic; 60 | } 61 | 62 | -(void)setTitle:(NSString *)title 63 | { 64 | _title = title; 65 | _polyline.title = _title; 66 | } 67 | 68 | -(void) setZIndex:(int)zIndex 69 | { 70 | _zIndex = zIndex; 71 | _polyline.zIndex = zIndex; 72 | } 73 | 74 | -(void)setTappable:(BOOL)tappable 75 | { 76 | _tappable = tappable; 77 | _polyline.tappable = tappable; 78 | } 79 | 80 | - (void)setOnPress:(RCTBubblingEventBlock)onPress { 81 | _polyline.onPress = onPress; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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+AirMap.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 | polyline.bridge = self.bridge; 30 | return polyline; 31 | } 32 | 33 | RCT_EXPORT_VIEW_PROPERTY(coordinates, AIRMapCoordinateArray) 34 | RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor) 35 | RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor) 36 | RCT_EXPORT_VIEW_PROPERTY(strokeWidth, double) 37 | RCT_EXPORT_VIEW_PROPERTY(geodesic, BOOL) 38 | RCT_EXPORT_VIEW_PROPERTY(zIndex, int) 39 | RCT_EXPORT_VIEW_PROPERTY(tappable, BOOL) 40 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | @"satellite": @(kGMSTypeSatellite), 17 | @"hybrid": @(kGMSTypeHybrid), 18 | @"terrain": @(kGMSTypeTerrain), 19 | @"none": @(kGMSTypeNone) 20 | } 21 | ), kGMSTypeTerrain, intValue) 22 | @end 23 | -------------------------------------------------------------------------------- /lib/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 "SMCalloutView.h" 15 | #import "RCTConvert+AirMap.h" 16 | 17 | extern const CLLocationDegrees AIRMapDefaultSpan; 18 | extern const NSTimeInterval AIRMapRegionChangeObserveInterval; 19 | extern const CGFloat AIRMapZoomBoundBuffer; 20 | extern const NSInteger AIRMapMaxZoomLevel; 21 | 22 | @interface AIRMap: MKMapView 23 | 24 | @property (nonatomic, strong) SMCalloutView *calloutView; 25 | @property (nonatomic, strong) UIImageView *cacheImageView; 26 | @property (nonatomic, strong) UIView *loadingView; 27 | 28 | @property (nonatomic, copy) NSString *userLocationAnnotationTitle; 29 | @property (nonatomic, assign) BOOL followUserLocation; 30 | @property (nonatomic, assign) BOOL hasStartedRendering; 31 | @property (nonatomic, assign) BOOL cacheEnabled; 32 | @property (nonatomic, assign) BOOL loadingEnabled; 33 | @property (nonatomic, strong) UIColor *loadingBackgroundColor; 34 | @property (nonatomic, strong) UIColor *loadingIndicatorColor; 35 | @property (nonatomic, assign) BOOL hasShownInitialLoading; 36 | @property (nonatomic, assign) CGFloat minDelta; 37 | @property (nonatomic, assign) CGFloat maxDelta; 38 | @property (nonatomic, assign) UIEdgeInsets legalLabelInsets; 39 | @property (nonatomic, strong) NSTimer *regionChangeObserveTimer; 40 | @property (nonatomic, assign) MKCoordinateRegion initialRegion; 41 | @property (nonatomic, assign) CGFloat minZoomLevel; 42 | @property (nonatomic, assign) CGFloat maxZoomLevel; 43 | 44 | @property (nonatomic, assign) CLLocationCoordinate2D pendingCenter; 45 | @property (nonatomic, assign) MKCoordinateSpan pendingSpan; 46 | 47 | 48 | @property (nonatomic, assign) BOOL ignoreRegionChanges; 49 | 50 | @property (nonatomic, copy) RCTBubblingEventBlock onMapReady; 51 | @property (nonatomic, copy) RCTBubblingEventBlock onChange; 52 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 53 | @property (nonatomic, copy) RCTBubblingEventBlock onPanDrag; 54 | @property (nonatomic, copy) RCTBubblingEventBlock onLongPress; 55 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerPress; 56 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerSelect; 57 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDeselect; 58 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDragStart; 59 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDrag; 60 | @property (nonatomic, copy) RCTDirectEventBlock onMarkerDragEnd; 61 | @property (nonatomic, copy) RCTDirectEventBlock onCalloutPress; 62 | @property (nonatomic, copy) RCTDirectEventBlock onRegionChange; 63 | 64 | - (void)cacheViewIfNeeded; 65 | - (void)beginLoading; 66 | - (void)finishLoading; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | 14 | #import "AIRMapCoordinate.h" 15 | #import "AIRMap.h" 16 | #import "RCTConvert+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 | -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapLocalTile.h: -------------------------------------------------------------------------------- 1 | // 2 | // AIRMapLocalTile.h 3 | // AirMaps 4 | // 5 | // Created by Peter Zavadsky on 01/12/2017. 6 | // Copyright © 2017 Christopher. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | #import "AIRMapCoordinate.h" 16 | #import "AIRMap.h" 17 | #import "RCTConvert+AirMap.h" 18 | 19 | @interface AIRMapLocalTile : 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 *pathTemplate; 27 | @property (nonatomic, assign) CGFloat tileSize; 28 | 29 | #pragma mark MKOverlay protocol 30 | 31 | @property(nonatomic, readonly) CLLocationCoordinate2D coordinate; 32 | @property(nonatomic, readonly) MKMapRect boundingMapRect; 33 | //- (BOOL)intersectsMapRect:(MKMapRect)mapRect; 34 | - (BOOL)canReplaceMapContent; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapLocalTile.m: -------------------------------------------------------------------------------- 1 | // 2 | // AIRMapLocalTile.m 3 | // AirMaps 4 | // 5 | // Created by Peter Zavadsky on 01/12/2017. 6 | // Copyright © 2017 Christopher. All rights reserved. 7 | // 8 | 9 | #import "AIRMapLocalTile.h" 10 | #import 11 | #import "AIRMapLocalTileOverlay.h" 12 | 13 | @implementation AIRMapLocalTile { 14 | BOOL _pathTemplateSet; 15 | BOOL _tileSizeSet; 16 | } 17 | 18 | 19 | - (void)setPathTemplate:(NSString *)pathTemplate{ 20 | _pathTemplate = pathTemplate; 21 | _pathTemplateSet = YES; 22 | [self createTileOverlayAndRendererIfPossible]; 23 | [self update]; 24 | } 25 | 26 | - (void)setTileSize:(CGFloat)tileSize{ 27 | _tileSize = tileSize; 28 | _tileSizeSet = YES; 29 | [self createTileOverlayAndRendererIfPossible]; 30 | [self update]; 31 | } 32 | 33 | - (void) createTileOverlayAndRendererIfPossible 34 | { 35 | if (!_pathTemplateSet || !_tileSizeSet) return; 36 | self.tileOverlay = [[AIRMapLocalTileOverlay alloc] initWithURLTemplate:self.pathTemplate]; 37 | self.tileOverlay.canReplaceMapContent = YES; 38 | self.tileOverlay.tileSize = CGSizeMake(_tileSize, _tileSize); 39 | self.renderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:self.tileOverlay]; 40 | } 41 | 42 | - (void) update 43 | { 44 | if (!_renderer) return; 45 | 46 | if (_map == nil) return; 47 | [_map removeOverlay:self]; 48 | [_map addOverlay:self level:MKOverlayLevelAboveLabels]; 49 | } 50 | 51 | #pragma mark MKOverlay implementation 52 | 53 | - (CLLocationCoordinate2D) coordinate 54 | { 55 | return self.tileOverlay.coordinate; 56 | } 57 | 58 | - (MKMapRect) boundingMapRect 59 | { 60 | return self.tileOverlay.boundingMapRect; 61 | } 62 | 63 | - (BOOL)canReplaceMapContent 64 | { 65 | return self.tileOverlay.canReplaceMapContent; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapLocalTileManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AIRMapLocalTileManager.h 3 | // AirMaps 4 | // 5 | // Created by Peter Zavadsky on 01/12/2017. 6 | // Copyright © 2017 Christopher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AIRMapLocalTileManager : RCTViewManager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapLocalTileManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // AIRMapLocalTileManager.m 3 | // AirMaps 4 | // 5 | // Created by Peter Zavadsky on 01/12/2017. 6 | // Copyright © 2017 Christopher. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import "AIRMapMarker.h" 16 | #import "AIRMapLocalTile.h" 17 | 18 | #import "AIRMapLocalTileManager.h" 19 | 20 | @interface AIRMapLocalTileManager() 21 | 22 | @end 23 | 24 | @implementation AIRMapLocalTileManager 25 | 26 | 27 | RCT_EXPORT_MODULE() 28 | 29 | - (UIView *)view 30 | { 31 | AIRMapLocalTile *tile = [AIRMapLocalTile new]; 32 | return tile; 33 | } 34 | 35 | RCT_EXPORT_VIEW_PROPERTY(pathTemplate, NSString) 36 | RCT_EXPORT_VIEW_PROPERTY(tileSize, CGFloat) 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapLocalTileOverlay.h: -------------------------------------------------------------------------------- 1 | // 2 | // AIRMapLocalTileOverlay.h 3 | // Pods 4 | // 5 | // Created by Peter Zavadsky on 04/12/2017. 6 | // 7 | 8 | #import 9 | 10 | @interface AIRMapLocalTileOverlay : MKTileOverlay 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapLocalTileOverlay.m: -------------------------------------------------------------------------------- 1 | // 2 | // AIRMapLocalTileOverlay.m 3 | // Pods-AirMapsExplorer 4 | // 5 | // Created by Peter Zavadsky on 04/12/2017. 6 | // 7 | 8 | #import "AIRMapLocalTileOverlay.h" 9 | 10 | @interface AIRMapLocalTileOverlay () 11 | 12 | @end 13 | 14 | @implementation AIRMapLocalTileOverlay 15 | 16 | 17 | -(void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result { 18 | NSMutableString *tileFilePath = [self.URLTemplate mutableCopy]; 19 | [tileFilePath replaceOccurrencesOfString: @"{x}" withString:[NSString stringWithFormat:@"%i", path.x] options:NULL range:NSMakeRange(0, tileFilePath.length)]; 20 | [tileFilePath replaceOccurrencesOfString:@"{y}" withString:[NSString stringWithFormat:@"%i", path.y] options:NULL range:NSMakeRange(0, tileFilePath.length)]; 21 | [tileFilePath replaceOccurrencesOfString:@"{z}" withString:[NSString stringWithFormat:@"%i", path.z] options:NULL range:NSMakeRange(0, tileFilePath.length)]; 22 | if ([[NSFileManager defaultManager] fileExistsAtPath:tileFilePath]) { 23 | NSData* tile = [NSData dataWithContentsOfFile:tileFilePath]; 24 | result(tile,nil); 25 | } else { 26 | result(nil, nil); 27 | } 28 | } 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /lib/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 | #import "AIRMap.h" 12 | 13 | #define MERCATOR_RADIUS 85445659.44705395 14 | #define MERCATOR_OFFSET 268435456 15 | 16 | @interface AIRMapManager : RCTViewManager 17 | 18 | 19 | - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate 20 | zoomLevel:(double)zoomLevel 21 | animated:(BOOL)animated 22 | mapView:(AIRMap *)mapView; 23 | 24 | - (MKCoordinateRegion)coordinateRegionWithMapView:(AIRMap *)mapView 25 | centerCoordinate:(CLLocationCoordinate2D)centerCoordinate 26 | andZoomLevel:(double)zoomLevel; 27 | - (double) zoomLevel:(AIRMap *)mapView; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /lib/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 "AIRMap.h" 18 | #import "SMCalloutView.h" 19 | #import "RCTConvert+AirMap.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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 "AIRMapCoordinate.h" 14 | #import "AIRMap.h" 15 | #import "RCTConvert+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 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapPolygon.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Leland Richardson on 12/27/15. 3 | // Copyright (c) 2015 Facebook. All rights reserved. 4 | // 5 | 6 | #import "AIRMapPolygon.h" 7 | #import 8 | 9 | 10 | @implementation AIRMapPolygon { 11 | 12 | } 13 | 14 | - (void)setFillColor:(UIColor *)fillColor { 15 | _fillColor = fillColor; 16 | [self update]; 17 | } 18 | 19 | - (void)setStrokeColor:(UIColor *)strokeColor { 20 | _strokeColor = strokeColor; 21 | [self update]; 22 | } 23 | 24 | - (void)setStrokeWidth:(CGFloat)strokeWidth { 25 | _strokeWidth = strokeWidth; 26 | [self update]; 27 | } 28 | 29 | - (void)setLineJoin:(CGLineJoin)lineJoin { 30 | _lineJoin = lineJoin; 31 | [self update]; 32 | } 33 | 34 | - (void)setLineCap:(CGLineCap)lineCap { 35 | _lineCap = lineCap; 36 | [self update]; 37 | } 38 | 39 | - (void)setMiterLimit:(CGFloat)miterLimit { 40 | _miterLimit = miterLimit; 41 | [self update]; 42 | } 43 | 44 | - (void)setLineDashPhase:(CGFloat)lineDashPhase { 45 | _lineDashPhase = lineDashPhase; 46 | [self update]; 47 | } 48 | 49 | - (void)setLineDashPattern:(NSArray *)lineDashPattern { 50 | _lineDashPattern = lineDashPattern; 51 | [self update]; 52 | } 53 | 54 | - (void)setCoordinates:(NSArray *)coordinates { 55 | _coordinates = coordinates; 56 | CLLocationCoordinate2D coords[coordinates.count]; 57 | for(int i = 0; i < coordinates.count; i++) 58 | { 59 | coords[i] = coordinates[i].coordinate; 60 | } 61 | self.polygon = [MKPolygon polygonWithCoordinates:coords count:coordinates.count interiorPolygons:_interiorPolygons]; 62 | // TODO: we could lazy-initialize the polygon, since we don't need it until the 63 | // polygon is in view. 64 | self.renderer = [[MKPolygonRenderer alloc] initWithPolygon:self.polygon]; 65 | [self update]; 66 | } 67 | 68 | - (void)setHoles:(NSArray *> *)holes { 69 | _holes = holes; 70 | if (holes.count) 71 | { 72 | NSMutableArray *polygons = [NSMutableArray array]; 73 | for(int h = 0; h < holes.count; h++) 74 | { 75 | CLLocationCoordinate2D coords[holes[h].count]; 76 | for(int i = 0; i < holes[h].count; i++) 77 | { 78 | coords[i] = holes[h][i].coordinate; 79 | } 80 | [polygons addObject:[MKPolygon polygonWithCoordinates:coords count:holes[h].count]]; 81 | } 82 | _interiorPolygons = polygons; 83 | } 84 | } 85 | 86 | - (void) update 87 | { 88 | if (!_renderer) return; 89 | _renderer.fillColor = _fillColor; 90 | _renderer.strokeColor = _strokeColor; 91 | _renderer.lineWidth = _strokeWidth; 92 | _renderer.lineCap = _lineCap; 93 | _renderer.lineJoin = _lineJoin; 94 | _renderer.miterLimit = _miterLimit; 95 | _renderer.lineDashPhase = _lineDashPhase; 96 | _renderer.lineDashPattern = _lineDashPattern; 97 | 98 | if (_map == nil) return; 99 | [_map removeOverlay:self]; 100 | [_map addOverlay:self]; 101 | } 102 | 103 | #pragma mark MKOverlay implementation 104 | 105 | - (CLLocationCoordinate2D) coordinate 106 | { 107 | return self.polygon.coordinate; 108 | } 109 | 110 | - (MKMapRect) boundingMapRect 111 | { 112 | return self.polygon.boundingMapRect; 113 | } 114 | 115 | - (BOOL)intersectsMapRect:(MKMapRect)mapRect 116 | { 117 | BOOL answer = [self.polygon intersectsMapRect:mapRect]; 118 | return answer; 119 | } 120 | 121 | - (BOOL)canReplaceMapContent 122 | { 123 | return NO; 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 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | @end 179 | -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/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+AirMap.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 | -------------------------------------------------------------------------------- /lib/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 "AIRMapCoordinate.h" 14 | #import "AIRMap.h" 15 | #import "RCTConvert+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) MKOverlayPathRenderer *renderer; 24 | 25 | @property (nonatomic, strong) NSArray *coordinates; 26 | @property (nonatomic, strong) UIColor *fillColor; 27 | @property (nonatomic, strong) UIColor *strokeColor; 28 | @property (nonatomic, strong) NSArray *strokeColors; 29 | @property (nonatomic, assign) CGFloat strokeWidth; 30 | @property (nonatomic, assign) CGFloat miterLimit; 31 | @property (nonatomic, assign) CGLineCap lineCap; 32 | @property (nonatomic, assign) CGLineJoin lineJoin; 33 | @property (nonatomic, assign) CGFloat lineDashPhase; 34 | @property (nonatomic, strong) NSArray *lineDashPattern; 35 | @property (nonatomic, copy) RCTBubblingEventBlock onPress; 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 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapPolyline.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Leland Richardson on 12/27/15. 3 | // Copyright (c) 2015 Facebook. All rights reserved. 4 | // 5 | 6 | #import "AIRMapPolyline.h" 7 | #import "AIRMapPolylineRenderer.h" 8 | #import 9 | 10 | 11 | @implementation AIRMapPolyline { 12 | 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)setStrokeColors:(NSArray *)strokeColors { 26 | _strokeColors = strokeColors; 27 | if ((self.renderer != nil) && ![_renderer isKindOfClass:[AIRMapPolylineRenderer class]]) { 28 | self.renderer = [self createRenderer]; 29 | } 30 | [self update]; 31 | } 32 | 33 | - (void)setStrokeWidth:(CGFloat)strokeWidth { 34 | _strokeWidth = strokeWidth; 35 | [self update]; 36 | } 37 | 38 | - (void)setLineJoin:(CGLineJoin)lineJoin { 39 | _lineJoin = lineJoin; 40 | [self update]; 41 | } 42 | 43 | - (void)setLineCap:(CGLineCap)lineCap { 44 | _lineCap = lineCap; 45 | [self update]; 46 | } 47 | 48 | - (void)setMiterLimit:(CGFloat)miterLimit { 49 | _miterLimit = miterLimit; 50 | [self update]; 51 | } 52 | 53 | - (void)setLineDashPhase:(CGFloat)lineDashPhase { 54 | _lineDashPhase = lineDashPhase; 55 | [self update]; 56 | } 57 | 58 | - (void)setLineDashPattern:(NSArray *)lineDashPattern { 59 | _lineDashPattern = lineDashPattern; 60 | [self update]; 61 | } 62 | 63 | - (void)setCoordinates:(NSArray *)coordinates { 64 | _coordinates = coordinates; 65 | CLLocationCoordinate2D coords[coordinates.count]; 66 | for(int i = 0; i < coordinates.count; i++) 67 | { 68 | coords[i] = coordinates[i].coordinate; 69 | } 70 | self.polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count]; 71 | self.renderer = [self createRenderer]; 72 | [self update]; 73 | } 74 | 75 | - (MKOverlayPathRenderer*)createRenderer { 76 | if (self.polyline == nil) return nil; 77 | if (self.strokeColors == nil) { 78 | // Use the default renderer when no array of stroke-colors is defined. 79 | // This behaviour may be changed in the future if we permanently want to 80 | // use the custom renderer, because it can add funtionality that is not 81 | // supported by the default renderer. 82 | return [[MKPolylineRenderer alloc] initWithPolyline:self.polyline]; 83 | } 84 | else { 85 | return [[AIRMapPolylineRenderer alloc] initWithOverlay:self polyline:self.polyline]; 86 | } 87 | } 88 | 89 | - (void) update 90 | { 91 | if (!_renderer) return; 92 | [self updateRenderer:_renderer]; 93 | 94 | if (_map == nil) return; 95 | [_map removeOverlay:self]; 96 | [_map addOverlay:self]; 97 | } 98 | 99 | - (void) updateRenderer:(MKOverlayPathRenderer*)renderer { 100 | renderer.fillColor = _fillColor; 101 | renderer.strokeColor = _strokeColor; 102 | renderer.lineWidth = _strokeWidth; 103 | renderer.lineCap = _lineCap; 104 | renderer.lineJoin = _lineJoin; 105 | renderer.miterLimit = _miterLimit; 106 | renderer.lineDashPhase = _lineDashPhase; 107 | renderer.lineDashPattern = _lineDashPattern; 108 | 109 | if ([renderer isKindOfClass:[AIRMapPolylineRenderer class]]) { 110 | ((AIRMapPolylineRenderer*)renderer).strokeColors = _strokeColors; 111 | } 112 | } 113 | 114 | #pragma mark MKOverlay implementation 115 | 116 | - (CLLocationCoordinate2D) coordinate 117 | { 118 | return self.polyline.coordinate; 119 | } 120 | 121 | - (MKMapRect) boundingMapRect 122 | { 123 | return self.polyline.boundingMapRect; 124 | } 125 | 126 | - (BOOL)intersectsMapRect:(MKMapRect)mapRect 127 | { 128 | BOOL answer = [self.polyline intersectsMapRect:mapRect]; 129 | return answer; 130 | } 131 | 132 | - (BOOL)canReplaceMapContent 133 | { 134 | return NO; 135 | } 136 | 137 | 138 | #pragma mark AIRMapSnapshot implementation 139 | 140 | - (void) drawToSnapshot:(MKMapSnapshot *) snapshot context:(CGContextRef) context 141 | { 142 | AIRMapPolylineRenderer* renderer = [[AIRMapPolylineRenderer alloc] initWithSnapshot:snapshot overlay:self polyline:self.polyline]; 143 | [self updateRenderer:renderer]; 144 | [renderer drawWithZoomScale:2 inContext:context]; 145 | } 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /lib/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 -------------------------------------------------------------------------------- /lib/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+AirMap.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(strokeColors, UIColorArray) 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 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/AIRMapPolylineRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // AIRMapPolylineRenderer.h 3 | // mapDemo 4 | // 5 | // Created by IjzerenHein on 13-11-21. 6 | // Copyright (c) 2017 IjzerenHein. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AIRMapPolylineRenderer : MKOverlayPathRenderer 12 | 13 | -(id)initWithOverlay:(id)overlay polyline:(MKPolyline*)polyline; 14 | -(id)initWithSnapshot:(MKMapSnapshot*)snapshot overlay:(id)overlay polyline:(MKPolyline*)polyline; 15 | -(void)drawWithZoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context; 16 | 17 | @property (nonatomic, strong) NSArray *strokeColors; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 "AIRMapCoordinate.h" 16 | #import "AIRMap.h" 17 | #import "RCTConvert+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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/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 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/RCTConvert+AirMap.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 (AirMap) 11 | 12 | + (MKCoordinateSpan)MKCoordinateSpan:(id)json; 13 | + (MKCoordinateRegion)MKCoordinateRegion:(id)json; 14 | + (MKMapType)MKMapType:(id)json; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /lib/ios/AirMaps/RCTConvert+AirMap.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Leland Richardson on 12/27/15. 3 | // Copyright (c) 2015 Facebook. All rights reserved. 4 | // 5 | 6 | #import "RCTConvert+AirMap.h" 7 | 8 | #import 9 | #import "AIRMapCoordinate.h" 10 | 11 | @implementation RCTConvert (AirMap) 12 | 13 | + (MKCoordinateSpan)MKCoordinateSpan:(id)json 14 | { 15 | json = [self NSDictionary:json]; 16 | return (MKCoordinateSpan){ 17 | [self CLLocationDegrees:json[@"latitudeDelta"]], 18 | [self CLLocationDegrees:json[@"longitudeDelta"]] 19 | }; 20 | } 21 | 22 | + (MKCoordinateRegion)MKCoordinateRegion:(id)json 23 | { 24 | return (MKCoordinateRegion){ 25 | [self CLLocationCoordinate2D:json], 26 | [self MKCoordinateSpan:json] 27 | }; 28 | } 29 | 30 | RCT_ENUM_CONVERTER(MKMapType, (@{ 31 | @"standard": @(MKMapTypeStandard), 32 | @"satellite": @(MKMapTypeSatellite), 33 | @"hybrid": @(MKMapTypeHybrid), 34 | @"satelliteFlyover": @(MKMapTypeSatelliteFlyover), 35 | @"hybridFlyover": @(MKMapTypeHybridFlyover), 36 | @"mutedStandard": @(MKMapTypeMutedStandard) 37 | }), MKMapTypeStandard, integerValue) 38 | 39 | // NOTE(lmr): 40 | // This is a bit of a hack, but I'm using this class to simply wrap 41 | // around a `CLLocationCoordinate2D`, since I was unable to figure out 42 | // how to handle an array of structs like CLLocationCoordinate2D. Would love 43 | // to get rid of this if someone can show me how... 44 | + (AIRMapCoordinate *)AIRMapCoordinate:(id)json 45 | { 46 | AIRMapCoordinate *coord = [AIRMapCoordinate new]; 47 | coord.coordinate = [self CLLocationCoordinate2D:json]; 48 | return coord; 49 | } 50 | 51 | RCT_ARRAY_CONVERTER(AIRMapCoordinate) 52 | 53 | + (NSArray *> *)AIRMapCoordinateArrayArray:(id)json 54 | { 55 | return RCTConvertArrayValue(@selector(AIRMapCoordinateArray:), json); 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-open-street-map", 3 | "description": "React Native Mapview component for Android", 4 | "main": "index.js", 5 | "author": "Enieber Cunha ", 6 | "version": "2.0.1", 7 | "scripts": { 8 | "start": "node node_modules/react-native/local-cli/cli.js start", 9 | "test": "jest", 10 | "run:packager": "./node_modules/react-native/packager/packager.sh", 11 | "run:ios": "react-native run-ios --project-path ./example/ios", 12 | "start:android": "adb shell am start -n com.airbnb.android.react.maps.example/.MainActivity", 13 | "run:android": "./gradlew installDebug && npm run start:android", 14 | "lint": "eslint ./", 15 | "build": "npm run build:js && npm run build:android && npm run build:ios", 16 | "build:js": "exit 0", 17 | "build:ios": "bundle install --binstubs ./examples/ios && bundle exec pod install --project-directory=./example/ios/", 18 | "build:android": "./gradlew :react-native-maps:assembleDebug", 19 | "ci": "npm run lint", 20 | "preversion": "./scripts/update-version.js" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "https://github.com/enieber/react-native-open-street-map" 25 | }, 26 | "keywords": [ 27 | "react", 28 | "react-native", 29 | "react-component", 30 | "map", 31 | "mapview", 32 | "open-street-map", 33 | "mapkit" 34 | ], 35 | "peerDependencies": { 36 | "prop-types": "^15.5.10", 37 | "react": "16.13.1", 38 | "react-native": "0.63.4" 39 | }, 40 | "devDependencies": { 41 | "@babel/core": "^7.12.10", 42 | "@babel/runtime": "^7.12.5", 43 | "babel-eslint": "^6.1.2", 44 | "babel-plugin-module-resolver": "^4.0.0", 45 | "babel-preset-airbnb": "^1.1.1", 46 | "babel-preset-react-native": "1.9.0", 47 | "eslint": "^3.3.1", 48 | "eslint-config-airbnb": "^10.0.1", 49 | "eslint-plugin-import": "^1.14.0", 50 | "eslint-plugin-jsx-a11y": "^2.1.0", 51 | "eslint-plugin-prefer-object-spread": "^1.1.0", 52 | "eslint-plugin-react": "^6.1.2", 53 | "gitbook-cli": "^2.3.0", 54 | "jest": "^22.0.4", 55 | "lodash": "^4.17.2", 56 | "metro-react-native-babel-preset": "^0.64.0", 57 | "prop-types": "^15.5.10", 58 | "react": "16.13.0", 59 | "react-native": "0.63.4" 60 | }, 61 | "rnpm": { 62 | "android": { 63 | "sourceDir": "./lib/android" 64 | } 65 | }, 66 | "jest": { 67 | "preset": "react-native" 68 | }, 69 | "dependencies": { 70 | "react-native-permissions": "^3.3.1" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /react-native-google-maps.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "react-native-google-maps" 7 | s.version = package['version'] 8 | s.summary = "React Native Mapview component for iOS + Android" 9 | 10 | s.authors = { "intelligibabble" => "leland.m.richardson@gmail.com" } 11 | s.homepage = "https://github.com/airbnb/react-native-maps#readme" 12 | s.license = "MIT" 13 | s.platform = :ios, "8.0" 14 | 15 | s.source = { :git => "https://github.com/airbnb/react-native-maps.git" } 16 | s.source_files = "lib/ios/AirGoogleMaps/**/*.{h,m}" 17 | s.compiler_flags = '-fno-modules' 18 | 19 | s.dependency 'React' 20 | s.dependency 'GoogleMaps', '2.5.0' 21 | end 22 | -------------------------------------------------------------------------------- /react-native-maps.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "react-native-maps" 7 | s.version = package['version'] 8 | s.summary = "React Native Mapview component for iOS + Android" 9 | 10 | s.authors = { "intelligibabble" => "leland.m.richardson@gmail.com" } 11 | s.homepage = "https://github.com/airbnb/react-native-maps#readme" 12 | s.license = "MIT" 13 | s.platform = :ios, "8.0" 14 | 15 | s.source = { :git => "https://github.com/airbnb/react-native-maps.git" } 16 | s.source_files = "lib/ios/AirMaps/**/*.{h,m}" 17 | 18 | s.dependency 'React' 19 | end 20 | -------------------------------------------------------------------------------- /rn-cli.config.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | /** 3 | * Returns a regular expression for modules that should be ignored by the 4 | * packager on a given platform. 5 | */ 6 | getBlacklistRE() { 7 | return /_book\//; 8 | }, 9 | }; 10 | 11 | module.exports = config; 12 | -------------------------------------------------------------------------------- /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 | * x react-native-maps.podspec // <-- this is now dynamic 9 | * x react-native-google-maps.podspec // <-- this is now dynamic 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 | ]; 20 | 21 | function doExec(cmdString) { 22 | return new Promise((resolve, reject) => { 23 | exec(cmdString, (err, stdout) => { 24 | if (err) { 25 | reject(err); 26 | return; 27 | } 28 | resolve(stdout); 29 | }); 30 | }); 31 | } 32 | 33 | function updateVersionInFile(currentVersion, nextVersion, relativePath) { 34 | process.stdout.write(`• ${relativePath}\n`); 35 | return doExec(`sed -i '' 's/${ 36 | escapeDots(currentVersion) 37 | }/${ 38 | escapeDots(nextVersion) 39 | }/g' ./${relativePath}`); 40 | } 41 | 42 | function escapeDots(version) { 43 | return version.replace(/\./g, '\\.'); 44 | } 45 | 46 | function run() { 47 | const currentVersion = pkg.version; 48 | const nextVersion = process.env.npm_package_version; 49 | 50 | Promise.resolve() 51 | .then(() => updateFiles(currentVersion, nextVersion)) 52 | .then(() => gitAdd()); 53 | } 54 | 55 | // Tasks 56 | 57 | function updateFiles(currentVersion, nextVersion) { 58 | process.stdout.write(`Updating ${currentVersion} ➞ ${nextVersion}:\n`); 59 | return Promise.all(filesToUpdate.map(relativePath => 60 | updateVersionInFile(currentVersion, nextVersion, relativePath) 61 | )); 62 | } 63 | 64 | function gitAdd() { 65 | return doExec(`git add ${filesToUpdate.join(' ')}`); 66 | } 67 | 68 | // Do it. 69 | 70 | run(); 71 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'react-native-maps' 2 | 3 | include ":example-android" 4 | project(":example-android").projectDir = file("./example/android/app") 5 | 6 | include ":react-native-maps-lib" 7 | project(":react-native-maps-lib").projectDir = file("./lib/android") 8 | --------------------------------------------------------------------------------