Skip to content

Commit

Permalink
Fly to location works
Browse files Browse the repository at this point in the history
Signed-off-by: Celine Pöhl <[email protected]>
  • Loading branch information
CelineMP committed Jun 3, 2024
1 parent 1f86be2 commit 85a43c7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions frontend/src/components/PopUp/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SearchBar: React.FC = () => {
}
const results = await provider.search({ query });
const transformedResults: MapSelection[] = results.map((result) => ({
coordinates: new LatLng(result.x, result.y),
coordinates: new LatLng(result.y, result.x),
displayName: result.label,
}));
callback(transformedResults);
Expand Down Expand Up @@ -84,15 +84,14 @@ const SearchBar: React.FC = () => {

const onItemSelected = (item: MapSelection) => {
setTimeout(() => {
alert(item.displayName);
flyToLocation(new LatLng(item.coordinates.lat, item.coordinates.lng));
}, 400);
};

const flyToLocation = (targetPosition: LatLng) => {
const { mapInstance } = currentMapCache;
if (mapInstance) {
mapInstance.flyTo(targetPosition, 13, { animate: true, duration: 10 });
mapInstance.flyTo(targetPosition, 13, { animate: true, duration: 5 });
} else console.log("no map instance");
};

Expand Down

0 comments on commit 85a43c7

Please sign in to comment.