Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bicycling option for travelType #77

Open
0x3dev opened this issue Jun 1, 2023 · 1 comment
Open

Add bicycling option for travelType #77

0x3dev opened this issue Jun 1, 2023 · 1 comment

Comments

@0x3dev
Copy link

0x3dev commented Jun 1, 2023

Hello. For Google Maps at least, there is a bicycling option. Can we have it in this library too? Thanks!

https://developers.google.com/maps/documentation/javascript/directions#TravelModes

@huygo88
Copy link

huygo88 commented Aug 1, 2024

For those looking to support bicycling, you can patch the package with the following:

  • Google Maps: pass bicycling as travelmode
  • Apple Maps: pass c as dirflg

Use patch-package:

patches/react-native-open-maps+0.4.3.patch

diff --git a/node_modules/react-native-open-maps/index.d.ts b/node_modules/react-native-open-maps/index.d.ts
index c0a8691..b365e0f 100644
--- a/node_modules/react-native-open-maps/index.d.ts
+++ b/node_modules/react-native-open-maps/index.d.ts
@@ -13,7 +13,7 @@ declare module 'react-native-open-maps' {
     /** Google Maps: Will use a Place ID for the query for Google Maps */
     queryPlaceId?: string
     /** Use this parameter in conjunction with start and end to determine transportation type. Default is drive "drive". */
-    travelType?: 'drive' | 'walk' | 'public_transport'
+    travelType?: 'drive' | 'walk' | 'public_transport' | 'bike'
     /** The start location that can be interpreted as a geolocation, omit if you want to use current location / "My Location". See Apple and Google docs for more details on how to define geolocations. "New York City, New York, NY" */
     start?: string
     /** The end location that can be interpreted as a geolocation. See Apple and Google docs for more details on how to define geolocations. Example: "SOHO, New York, NY" */
diff --git a/node_modules/react-native-open-maps/index.js b/node_modules/react-native-open-maps/index.js
index 2ff95fa..ff26067 100644
--- a/node_modules/react-native-open-maps/index.js
+++ b/node_modules/react-native-open-maps/index.js
@@ -20,7 +20,7 @@ export const validateEnum = (enums = []) => (type) => {
 	return true;
 }
 
-export const validateTravelType = validateEnum(['drive', 'walk', 'public_transport']);
+export const validateTravelType = validateEnum(['drive', 'walk', 'public_transport', 'bike']);
 export const validateMapType = validateEnum(['standard', 'satellite', 'hybrid', 'transit']);
 
 // cleanObject :: {} -> {}
@@ -39,7 +39,8 @@ export const createAppleParams = options => {
 	const travelTypeMap = {
 		drive: 'd',
 		walk: 'w',
-		public_transport: 'r'
+		public_transport: 'r',
+		bike: 'c'
 	};
 
 	const baseTypeMap = {
@@ -78,7 +79,8 @@ export const createGoogleParams = options => {
 	const travelTypeMap = {
 		drive: 'driving',
 		walk: 'walking',
-		public_transport: 'transit'
+		public_transport: 'transit',
+		bike: 'bicycling'
 	};
 
 	const baseTypeMap = {
@@ -121,7 +123,8 @@ export const createYandexParams = options => {
 	const travelTypeMap = {
 	  	drive: 'auto',
 	  	walk: 'pd',
-	  	public_transport: 'mt'
+	  	public_transport: 'mt',
+			bike: 'auto'
 	};
 
 	const baseTypeMap = {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants