You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I value your hard work on this open street map and the (mapliber) packaes, we are always thank full to open-source devs
I’m using the UserLocation component from @maplibre/maplibre-react-native to track the user’s live location while navigating.
However, the onUpdate callback seems to fire only once when the component is mounted. It does not continuously emit updated coordinates as the user moves.
Currently I am working on a mobile app development for patrol system where we need to send the officer location for every 3 seconds, I am trying to use useLocaion component for that, but it trigger only while mounting time, so we are using react natvie community geo location package in addtion to get officer current coordiante. Please can you help me to solve this issue? Is it possible to get the user's continuously changing coordinates with the help of this maplib only, so we can eliminate other packages and reduce the load and complexity of the code? Please be kind enough to give a response on this issue, it's our major project. I am thankful to open-source devs always.
`import MapLibreRN, {
Camera, LineLayer, MapView, PointAnnotation, ShapeSource, UserLocation, UserTrackingMode,
type Location
} from '@maplibre/maplibre-react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Geolocation from '@react-native-community/geolocation';
import React, { useEffect, useRef, useState } from 'react';
import { ActivityIndicator, Alert, Animated, SafeAreaView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import CompassHeading from 'react-native-compass-heading';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import useMapHotspotData from '../../../api/partolDutyApi';
import {
closeWebSocket,
connectWebSocket,
sendEndPatrolMessage,
sendLocationViaWebSocket
} from '../../../api/webSocketService';
import { usePatrolRouteStore } from '../../../stores/po/PatrolRouteStore'; // adjust path as needed
import { Permission } from '../../../utils/Permission';
// api key
const apikey = ''; // key is removed
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I value your hard work on this open street map and the (mapliber) packaes, we are always thank full to open-source devs
I’m using the UserLocation component from @maplibre/maplibre-react-native to track the user’s live location while navigating.
However, the onUpdate callback seems to fire only once when the component is mounted. It does not continuously emit updated coordinates as the user moves.
Currently I am working on a mobile app development for patrol system where we need to send the officer location for every 3 seconds, I am trying to use useLocaion component for that, but it trigger only while mounting time, so we are using react natvie community geo location package in addtion to get officer current coordiante. Please can you help me to solve this issue? Is it possible to get the user's continuously changing coordinates with the help of this maplib only, so we can eliminate other packages and reduce the load and complexity of the code? Please be kind enough to give a response on this issue, it's our major project. I am thankful to open-source devs always.
`import MapLibreRN, {
Camera, LineLayer, MapView, PointAnnotation, ShapeSource, UserLocation, UserTrackingMode,
type Location
} from '@maplibre/maplibre-react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Geolocation from '@react-native-community/geolocation';
import React, { useEffect, useRef, useState } from 'react';
import { ActivityIndicator, Alert, Animated, SafeAreaView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import CompassHeading from 'react-native-compass-heading';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import useMapHotspotData from '../../../api/partolDutyApi';
import {
closeWebSocket,
connectWebSocket,
sendEndPatrolMessage,
sendLocationViaWebSocket
} from '../../../api/webSocketService';
import { usePatrolRouteStore } from '../../../stores/po/PatrolRouteStore'; // adjust path as needed
import { Permission } from '../../../utils/Permission';
// api key
const apikey = ''; // key is removed
const styleUrl =
https://api.maptiler.com/maps/streets/style.json?key=${apikey}
;// --- GeoJSON Type Definition ---
type GeoJSONFeature = {
type: "Feature";
geometry: {
type: "LineString";
coordinates: number[][];
},
properties: {};
};
// --- Permission Request Function (no changes needed) ---
const handlePermisson = async () => {
const { locationGranted } = await Permission();
if (locationGranted) {
return true;
} else {
return true;
}
};
interface MapContainerProps {
showRoute: boolean;
isNavigating: boolean;
setIsNavigating: (value: boolean) => void;
setShowRoute: (value: boolean) => void;
onNearHotspotChange: (isNear: boolean) => void;
}
const policeStaton = [76.31699739701845, 10.047201561214242];
const MapContainer: React.FC = ({ showRoute, isNavigating, setIsNavigating, setShowRoute, onNearHotspotChange }) => {
};
`
Beta Was this translation helpful? Give feedback.
All reactions