Skip to content

Commit e2b39c3

Browse files
fix: simulate location (#219)
* fix: iOS simulate location * fix: Android simulate location
1 parent df7a9f1 commit e2b39c3

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

android/src/main/java/com/google/android/react/navsdk/NavModule.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023 Google LLC
2+
* Copyright 2024 Google LLC
33
*
44
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
55
* except in compliance with the License. You may obtain a copy of the License at
@@ -610,15 +610,12 @@ private void sendCommandToReactNative(String functionName, String args) {
610610
}
611611
}
612612

613-
public void simulateLocation(Map map) {
613+
@ReactMethod
614+
public void simulateLocation(ReadableMap location) {
614615
if (mNavigator != null) {
615-
Double lat = null;
616-
Double lng = null;
617-
if (map.containsKey("location")) {
618-
Map latlng = (Map) map.get("location");
619-
if (latlng.get("lat") != null) lat = Double.parseDouble(latlng.get("lat").toString());
620-
if (latlng.get("lng") != null) lng = Double.parseDouble(latlng.get("lng").toString());
621-
}
616+
HashMap<String, Object> locationMap = location.toHashMap();
617+
Double lat = CollectionUtil.getDouble("lat", locationMap, 0);
618+
Double lng = CollectionUtil.getDouble("lng", locationMap, 0);
622619
mNavigator.getSimulator().setUserLocation(new LatLng(lat, lng));
623620
}
624621
}

ios/react-native-navigation-sdk/NavModule.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023 Google LLC
2+
* Copyright 2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -537,7 +537,7 @@ - (void)configureNavigator:(GMSNavigator *)navigator withRoutingOptions:(NSDicti
537537
[self->_session.locationSimulator
538538
simulateLocationAtCoordinate:
539539
[ObjectTranslationUtil
540-
getLocationCoordinateFrom:coordinates[@"location"]]];
540+
getLocationCoordinateFrom:coordinates]];
541541
}
542542
});
543543
}

0 commit comments

Comments
 (0)