Geofencing Assignment- 1

Basic Questions

  1. Write code using navigator.geolocation.getCurrentPosition() that logs current lat/lng every time a button is clicked.
  2. Implement a function that continuously watches user location with watchPosition() and logs updated coordinates.
  3. Create a geofence of 200m radius and log “Inside” when user enters, “Outside” otherwise.
  4. Build a function that calculates distance between user and a fixed point using Haversine formula.
  5. Implement entry detection: log “Entered Zone” only when moving from outside to inside.
  6. Implement exit detection: log “Exited Zone” only when moving from inside to outside.
  7. Create a function that detects stay: user should remain inside a 100m radius for 10s before printing “Stayed”.
  8. Simulate geolocation with random coordinates and test your entry/exit logic.
  9. Write a snippet that alerts the user if they are within 50m of a restaurant location.
  10. Implement geolocation error handling with custom error messages for each error code.
  11. Draw a circular geofence on Google Maps (200m radius) using google.maps.Circle().
  12. Write code that changes circle’s fill color when user enters the geofence.
  13. Implement a polygon-shaped geofence and check if random user coordinates fall inside it.
  14. Build a function that logs “Crossed Boundary” when user moves from one geofence circle to another.
  15. Write code to log geofence entry and exit events with timestamps.
  16. Implement a reusable function isInsideCircle(lat, lng, center, radius) that returns true/false.
  17. Simulate live tracking by moving a marker on Google Maps every 5s using random coordinates.
  18. Write a function that detects when user passes exactly on the geofence boundary (≈ radius distance).
  19. Build a snippet that stores last 5 entry/exit logs in localStorage.
  20. Create a button “Check Now” that instantly checks whether user is inside or outside a geofence.

Intermediate Questions

  1. Implement continuous distance logging every 5s between user and a fixed geofence center.
  2. Write code that detects entry into multiple circles and logs which geofence was entered.
  3. Build a stay detection system that resets timer if user exits before 10s inside.
  4. Use setInterval to check location every 3s and log “Monitoring…” plus user coordinates.
  5. Implement a system that highlights different geofence circles with unique colors.
  6. Write a program to dynamically generate 5 geofences from an array of coordinates.
  7. Build logic that alerts the user if they leave a polygon geofence (exit transition).
  8. Implement role-based logging where only “Admin” can view entry/exit logs.
  9. Write a function that saves all transition logs into an array and prints them on demand.
  10. Create a Google Maps app that draws both polygon and circle geofences on the same map.
  11. Build a function that shows “Inside Polygon” or “Outside Polygon” when user coordinates are tested.
  12. Implement code that fetches user location every 10s and pushes logs into localStorage.
  13. Write code that alerts “Safe Zone” if inside geofence, “Warning Zone” if within 50m of boundary.
  14. Create a stay transition detection for two users simultaneously using simulated coordinates.
  15. Implement entry transition detection with sound notification (new Audio(“alert.mp3”).play()).
  16. Write a function that dynamically increases geofence radius from 100m → 200m → 300m every 15s.
  17. Implement watchPosition with error handling and live location plotting on Google Maps.
  18. Build code that checks if user is inside any geofence from a list of multiple polygons.
  19. Write code to send entry/exit events to a mock API endpoint (/api/logs).
  20. Implement a geofence monitor that logs “Active” if user has at least one active geofence.

Advanced Questions

  1. Build a system that tracks Entry → Stay → Exit transitions and logs them in correct order.
  2. Implement multiple geofence manager where 3 polygons and 2 circles are active and tracked separately.
  3. Create Google Maps integration where user marker turns green inside, red outside geofence.
  4. Simulate a dashboard showing how many users are currently inside geofence (fake random coordinates).
  5. Implement stay detection for 5 simulated users, each with random movement paths.
  6. Write logic that triggers different API calls on transitions: /enter, /stay, /exit.
  7. Build a logging system that saves transition history to localStorage and renders a table UI.
  8. Implement polygon-based detection for a custom irregular zone (not a circle).
  9. Create a geofencing simulation that generates random paths and tests all Entry/Stay/Exit transitions.
  10. Develop a full geofencing solution with Google Maps: supports circles + polygons, logging, error handling, and stay detection.