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

Destination coordinates mixed #17

Closed
zoolle opened this issue Mar 2, 2021 · 4 comments
Closed

Destination coordinates mixed #17

zoolle opened this issue Mar 2, 2021 · 4 comments

Comments

@zoolle
Copy link

zoolle commented Mar 2, 2021

I was trying to run some tests with different locations and finally I figure out that the latitude and longitude are mixed up

let originWaypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: origin[1] as! CLLocationDegrees, longitude: origin[0] as! CLLocationDegrees)) let destinationWaypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: destination[1] as! CLLocationDegrees, longitude: destination[0] as! CLLocationDegrees))

Any reason for this?

I should expect origin=[latitude, longitude] and destination=[latitude, longitude]

@Kewal89
Copy link

Kewal89 commented Mar 2, 2021

It's probably because MapBox Location parameters (latitude and longitude) are standardized in that way.
Even <MapboxGL.Camera /> centerCoordinate props needs [lng, lat] as value.
Interchanging them will result in blank or incorrect response.

@zoolle
Copy link
Author

zoolle commented Mar 2, 2021

That's fine but at least we can put in component, [lat, lng] format and then handled from behind in mapbox standard. For example I am using Google maps to get the coordinates of origin and destination and I am passing origin and destination as objects the way Google maps generates it

@Kewal89
Copy link

Kewal89 commented Mar 2, 2021

Yeah. Not Sure But You Could Try array.reverse() or [...array].reverse() To Make It Work.

@rossmartin
Copy link
Contributor

This is an artifact of how this library evolved and also to stay consistent with @react-native-mapbox-gl/maps. I do agree that it really should be [lat, lng] but I don't plan to change this (for now at least). It is documented here and also with @react-native-mapbox-gl/maps. If I do change it to [lat, lng] I'll document the breaking change and do a major version bump.

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

3 participants