diff --git a/android/src/main/java/com/google/android/react/navsdk/NavModule.java b/android/src/main/java/com/google/android/react/navsdk/NavModule.java index b0814c3..f3c6dfa 100644 --- a/android/src/main/java/com/google/android/react/navsdk/NavModule.java +++ b/android/src/main/java/com/google/android/react/navsdk/NavModule.java @@ -1,5 +1,5 @@ /** - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * 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) { } } - public void simulateLocation(Map map) { + @ReactMethod + public void simulateLocation(ReadableMap location) { if (mNavigator != null) { - Double lat = null; - Double lng = null; - if (map.containsKey("location")) { - Map latlng = (Map) map.get("location"); - if (latlng.get("lat") != null) lat = Double.parseDouble(latlng.get("lat").toString()); - if (latlng.get("lng") != null) lng = Double.parseDouble(latlng.get("lng").toString()); - } + HashMap locationMap = location.toHashMap(); + Double lat = CollectionUtil.getDouble("lat", locationMap, 0); + Double lng = CollectionUtil.getDouble("lng", locationMap, 0); mNavigator.getSimulator().setUserLocation(new LatLng(lat, lng)); } } diff --git a/ios/react-native-navigation-sdk/NavModule.m b/ios/react-native-navigation-sdk/NavModule.m index 81f5722..f68a865 100644 --- a/ios/react-native-navigation-sdk/NavModule.m +++ b/ios/react-native-navigation-sdk/NavModule.m @@ -1,5 +1,5 @@ /** - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -537,7 +537,7 @@ - (void)configureNavigator:(GMSNavigator *)navigator withRoutingOptions:(NSDicti [self->_session.locationSimulator simulateLocationAtCoordinate: [ObjectTranslationUtil - getLocationCoordinateFrom:coordinates[@"location"]]]; + getLocationCoordinateFrom:coordinates]]; } }); }