Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add realtime device tracker | Issue #1623 #1663

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

Tusharb331
Copy link
Contributor

I have added a realtime device tracker | Issue #1623

Realtime Device Tracker

This is a mini project for tracking a device connected to our app in real-time. Similar to online delivery apps where you can see the rider's current location, this app smoothly tracks and displays your location continuously.

Tech Stack

  • Node.js
  • Express
  • EJS
  • Socket.io
  • Leaflet
  • OpenStreetMap

Project Workflow

  1. Check for Geolocation Support: Verify if the browser supports geolocation.
  2. Set Geolocation Options: Configure options for high accuracy, a 5-second timeout, and no caching.
  3. Track User Location: Use watchPosition to continuously track the user's location.
  4. Emit Location Data: Emit latitude and longitude via a socket with the event "send-location". Log any errors to the console.
  5. Initialize the Map: Center the map at coordinates (0,0) with a zoom level of 15 using Leaflet.
  6. Add Map Tiles: Add OpenStreetMap tiles to the map and create an empty object for markers.
  7. Handle Incoming Location Data: When receiving location data via the socket, extract the id, latitude, and longitude, and center the map on the new coordinates.
  8. Update or Add Markers: If a marker for the id exists, update its position. Otherwise, create a new marker at the given coordinates and add it to the map.
  9. Handle User Disconnects: When a user disconnects, remove their marker from the map and delete it from the markers object.

Features

  1. Real-time tracking of connected devices.
  2. Smooth location updates.
  3. User-friendly map interface.

Copy link

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for masterwebdevelopment ready!

Name Link
🔨 Latest commit c0a6178
🔍 Latest deploy log https://app.netlify.com/sites/masterwebdevelopment/deploys/6719148037399b00082c7289
😎 Deploy Preview https://deploy-preview-1663--masterwebdevelopment.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Tusharb331
Copy link
Contributor Author

@iamrahulmahato please review and merge with labels (gssoc-ext, hacktoberfest etc)

@iamrahulmahato iamrahulmahato added hacktoberfest pr for hacktoberfest hacktoberfest-accepted accept pr for hacktoberfest level1 gssoc-ext pr for GSSoC labels Oct 25, 2024
@iamrahulmahato iamrahulmahato merged commit d1e504b into iamrahulmahato:main Oct 25, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc-ext pr for GSSoC hacktoberfest pr for hacktoberfest hacktoberfest-accepted accept pr for hacktoberfest level1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants