Remove Polyline route drawing from map
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package com.rit.driver;
|
package com.rit.driver;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
// Replace this with your VPS public IP address or production domain name
|
// Local testing backend URL (Your PC Wi-Fi IP)
|
||||||
public static final String BACKEND_URL = "http://15.206.182.201:8085";
|
public static final String BACKEND_URL = "http://10.10.15.91:8085";
|
||||||
|
|
||||||
// Default driver security PIN
|
// Default driver security PIN
|
||||||
public static final String DEFAULT_PIN = "RITDRIVER";
|
public static final String DEFAULT_PIN = "RITDRIVER";
|
||||||
|
|||||||
@@ -133,18 +133,37 @@ public class TrackingService extends Service {
|
|||||||
Log.d(TAG, "WakeLock acquired successfully");
|
Log.d(TAG, "WakeLock acquired successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Register GPS location listener
|
// 3. Register Location Listeners (both GPS and Network for indoors/outdoors)
|
||||||
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||||
try {
|
try {
|
||||||
if (locationManager != null) {
|
if (locationManager != null) {
|
||||||
// Request updates every 5 seconds (5000ms) or 2 meters
|
// Request GPS updates
|
||||||
locationManager.requestLocationUpdates(
|
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||||
LocationManager.GPS_PROVIDER,
|
locationManager.requestLocationUpdates(
|
||||||
5000,
|
LocationManager.GPS_PROVIDER,
|
||||||
2.0f,
|
5000,
|
||||||
locationListener
|
0.0f,
|
||||||
);
|
locationListener
|
||||||
Log.d(TAG, "GPS Listener registered successfully");
|
);
|
||||||
|
}
|
||||||
|
// Request Network/Wi-Fi location updates (essential indoors)
|
||||||
|
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
||||||
|
locationManager.requestLocationUpdates(
|
||||||
|
LocationManager.NETWORK_PROVIDER,
|
||||||
|
5000,
|
||||||
|
0.0f,
|
||||||
|
locationListener
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Immediately trigger initial fix if available
|
||||||
|
Location lastGps = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
|
Location lastNet = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||||
|
Location bestLocation = (lastGps != null) ? lastGps : lastNet;
|
||||||
|
if (bestLocation != null) {
|
||||||
|
locationListener.onLocationChanged(bestLocation);
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Location Listeners registered successfully");
|
||||||
}
|
}
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Log.e(TAG, "SecurityException: Location permissions not granted", e);
|
Log.e(TAG, "SecurityException: Location permissions not granted", e);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { MapContainer, TileLayer, Marker, Popup, Polyline, useMap } from 'react-leaflet';
|
import { MapContainer, TileLayer, Marker, Popup, useMap } from 'react-leaflet';
|
||||||
import L from 'leaflet';
|
import L from 'leaflet';
|
||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
import type { BusRoute } from '@/types';
|
import type { BusRoute } from '@/types';
|
||||||
@@ -289,14 +289,6 @@ export default function BusRouteMap({ selectedRoute, allRoutes }: BusRouteMapPro
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{selectedRoute && pathCoordinates.length > 1 && (
|
|
||||||
<Polyline
|
|
||||||
positions={pathCoordinates}
|
|
||||||
color={selectedRoute.color || "#F97316"}
|
|
||||||
weight={4}
|
|
||||||
opacity={0.8}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<MapUpdater bounds={mapBounds} />
|
<MapUpdater bounds={mapBounds} />
|
||||||
</MapContainer>
|
</MapContainer>
|
||||||
|
|||||||
Reference in New Issue
Block a user