tschoffelen / react-native-map-link

🗺 Open the map app of the user's choice.
MIT License
663 stars 141 forks source link

Cannot use `address` prop. #292

Closed OwenMelbz closed 3 months ago

OwenMelbz commented 4 months ago

I think this was maybe introduced very recently, could have been a merge conflict gone wrong or what, I'm not sure, but Im trying to use this

showLocation({
    address: 'some address here'
})

However it is throwing the following error:

 ERROR  [MapsException: `showLocation` should contain keys `latitude` and `longitude`.]

When digging into the source code and the checkOptions function, the first check is for lat/lon - I think there is a left over condition here? e.g. should if (!latitude || !longitude) { have been removed, which would allow the lat/lon/address check to kick in? Additionally should the if (address && typeof address !== 'string') { check come after the lat/lon/address check?

const checkOptions = ({ latitude, longitude, address, googleForceLatLon, googlePlaceId, title, app, prefixes, appTitles, appsWhiteList, }) => {
    if (!latitude || !longitude) {
        throw new MapsException('`showLocation` should contain keys `latitude` and `longitude`.');
    }
    if (address && typeof address !== 'string') {
        throw new MapsException('Option `address` should be of type `string`.');
    }
    if (!latitude && !longitude && !address) {
        throw new MapsException('`latitude` & `longitude` or `address` is required. Both cannot be undefined.');
    }

Thanks!

tschoffelen commented 4 months ago

Good catch! Please feel free to submit a PR, happy to get that merged in!

OwenMelbz commented 4 months ago

https://github.com/includable/react-native-map-link/pull/293

github-actions[bot] commented 3 months ago

:tada: This issue has been resolved in version 3.5.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: