show my location on the map

This commit is contained in:
Bart Akeley 2020-04-05 20:32:30 -05:00
parent 2d3a706333
commit 6920ef7e0f
4 changed files with 18 additions and 4 deletions

View file

@ -1,15 +1,16 @@
// @flow
import React from 'react';
import { View } from 'react-native';
import { View, Image } from 'react-native';
import typeof FoodItemRecord from '../records/FoodItemRecord';
import { withFoodItems } from '../enhancers/foodItemEnhancers';
import { withLocation } from '../enhancers/locationEnhancers';
import { compose, renderComponent, withState, withProps } from 'recompose';
import { Map } from 'immutable';
import MapView from 'react-native-maps';
import MapView, { Marker } from 'react-native-maps';
import { routeWithTitle } from '../helpers/RouteHelpers';
import FoodItemTile from '../components/FoodItemTile';
import { getZoomBox } from '../helpers/CoordinatesHelpers';
import LOCATION_DOT from '../../static/location-dot.png';
type Region = {
latitude: number,
@ -23,14 +24,22 @@ type Props = {
location: Location,
initialRegion: Region,
region: Region,
onRegionChange: Region => void,
onRegionChange: (Region) => void,
pushRoute: () => {},
};
const FoodMap = ({ foodItemsMap, region, onRegionChange, pushRoute, initialRegion }: Props) => {
const FoodMap = ({
foodItemsMap,
region,
onRegionChange,
pushRoute,
initialRegion,
location,
}: Props) => {
if (!foodItemsMap) {
return null;
}
return (
<View style={{ flex: 1 }}>
<MapView
@ -57,6 +66,11 @@ const FoodMap = ({ foodItemsMap, region, onRegionChange, pushRoute, initialRegio
);
})
.toList()}
<Marker coordinate={location.coords}>
<View>
<Image source={LOCATION_DOT} style={{ height: 24, width: 24 }} resizeMode="contain" />
</View>
</Marker>
</MapView>
</View>
);

BIN
static/location-dot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
static/location-dot@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
static/location-dot@3x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB