place detail open in maps linking to geo app

This commit is contained in:
Bart Akeley 2018-05-06 10:58:04 -05:00
parent 5e0b6ccb5e
commit 03158e3c44

View file

@ -1,6 +1,6 @@
// @flow
import React, { Component } from 'react';
import { View, Image, ScrollView } from 'react-native';
import { View, Image, ScrollView, Linking } from 'react-native';
import theme from '../ui-theme';
import { compose, pure } from 'recompose';
import typeof PlaceRecord from '../records/PlaceRecord';
@ -51,8 +51,22 @@ export class PlaceDetail extends Component {
isFavorite: !prevState.isFavorite,
}));
// todo - build a map view and open it here
viewOnMap = () => {};
viewOnMap = () => {
const { place } = this.props;
if (!place) {
return;
}
const { latitude, longitude } = place;
const url = `geo:${latitude}, ${longitude}`;
Linking.canOpenURL(url)
.then(supported => {
if (supported) {
return Linking.openURL(url);
}
})
.catch(err => console.error('Failed to open geo URL', err)); // eslint-disable-line
};
// todo: need to get the item from the stream by this id
render() {