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

fix: simulate location #219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2023 Google LLC
* Copyright 2024 Google LLC
*
* <p>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
Expand Down Expand Up @@ -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<String, Object> locationMap = location.toHashMap();
Double lat = CollectionUtil.getDouble("lat", locationMap, 0);
Double lng = CollectionUtil.getDouble("lng", locationMap, 0);
mNavigator.getSimulator().setUserLocation(new LatLng(lat, lng));
}
}
Expand Down
4 changes: 2 additions & 2 deletions ios/react-native-navigation-sdk/NavModule.m
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -537,7 +537,7 @@ - (void)configureNavigator:(GMSNavigator *)navigator withRoutingOptions:(NSDicti
[self->_session.locationSimulator
simulateLocationAtCoordinate:
[ObjectTranslationUtil
getLocationCoordinateFrom:coordinates[@"location"]]];
getLocationCoordinateFrom:coordinates]];
}
});
}
Expand Down
Loading