Browse Source

Map focus in Brasil while loading user location

master
GabrielTrettel 4 years ago
parent
commit
4fa760a6c5
  1. 17
      src/app/screens/MapFeedScreen.js

17
src/app/screens/MapFeedScreen.js

@ -11,16 +11,19 @@ import attachFocusToQuery from "../hooks/useFocus";
import { CurrentLocationContext } from "../context/CurrentLocationContext"; import { CurrentLocationContext } from "../context/CurrentLocationContext";
function MapFeedScreen(props) { function MapFeedScreen(props) {
const context = useContext(CurrentLocationContext); const context = useContext(CurrentLocationContext);
const location = context.currentCoordinates; const location = context.currentCoordinates;
//const context = useContext(CurrentLocationContext)
const hasToQuery = attachFocusToQuery(); const hasToQuery = attachFocusToQuery();
const markers = useMarkers(hasToQuery); const markers = useMarkers(hasToQuery);
// console.log(markers);
const default_location = {
latitude: -12.901799,
longitude: -51.692116,
latitudeDelta: 70,
longitudeDelta: 70 * (screen_width / screen_height),
};
const map_scale = 0.003; const map_scale = 0.003;
const lat_long_delta = { const lat_long_delta = {
latitudeDelta: map_scale, latitudeDelta: map_scale,
@ -32,11 +35,7 @@ function MapFeedScreen(props) {
<MapView <MapView
style={styles.mapStyle} style={styles.mapStyle}
showsUserLocation={true} showsUserLocation={true}
initialRegion={{
latitude: -22.1070263,
longitude: -51.3948396,
...lat_long_delta,
}}
initialRegion={{ ...default_location }}
region={{ region={{
latitude: location["latitude"], latitude: location["latitude"],
longitude: location["longitude"], longitude: location["longitude"],

Loading…
Cancel
Save