Geofencing Assignment- 1
Basic Questions
- Write code using navigator.geolocation.getCurrentPosition() that logs current lat/lng every time a button is clicked.
- Implement a function that continuously watches user location with watchPosition() and logs updated coordinates.
- Create a geofence of 200m radius and log “Inside” when user enters, “Outside” otherwise.
- Build a function that calculates distance between user and a fixed point using Haversine formula.
- Implement entry detection: log “Entered Zone” only when moving from outside to inside.
- Implement exit detection: log “Exited Zone” only when moving from inside to outside.
- Create a function that detects stay: user should remain inside a 100m radius for 10s before printing “Stayed”.
- Simulate geolocation with random coordinates and test your entry/exit logic.
- Write a snippet that alerts the user if they are within 50m of a restaurant location.
- Implement geolocation error handling with custom error messages for each error code.
- Draw a circular geofence on Google Maps (200m radius) using google.maps.Circle().
- Write code that changes circle’s fill color when user enters the geofence.
- Implement a polygon-shaped geofence and check if random user coordinates fall inside it.
- Build a function that logs “Crossed Boundary” when user moves from one geofence circle to another.
- Write code to log geofence entry and exit events with timestamps.
- Implement a reusable function isInsideCircle(lat, lng, center, radius) that returns true/false.
- Simulate live tracking by moving a marker on Google Maps every 5s using random coordinates.
- Write a function that detects when user passes exactly on the geofence boundary (≈ radius distance).
- Build a snippet that stores last 5 entry/exit logs in localStorage.
- Create a button “Check Now” that instantly checks whether user is inside or outside a geofence.
Intermediate Questions
- Implement continuous distance logging every 5s between user and a fixed geofence center.
- Write code that detects entry into multiple circles and logs which geofence was entered.
- Build a stay detection system that resets timer if user exits before 10s inside.
- Use setInterval to check location every 3s and log “Monitoring…” plus user coordinates.
- Implement a system that highlights different geofence circles with unique colors.
- Write a program to dynamically generate 5 geofences from an array of coordinates.
- Build logic that alerts the user if they leave a polygon geofence (exit transition).
- Implement role-based logging where only “Admin” can view entry/exit logs.
- Write a function that saves all transition logs into an array and prints them on demand.
- Create a Google Maps app that draws both polygon and circle geofences on the same map.
- Build a function that shows “Inside Polygon” or “Outside Polygon” when user coordinates are tested.
- Implement code that fetches user location every 10s and pushes logs into localStorage.
- Write code that alerts “Safe Zone” if inside geofence, “Warning Zone” if within 50m of boundary.
- Create a stay transition detection for two users simultaneously using simulated coordinates.
- Implement entry transition detection with sound notification (new Audio(“alert.mp3”).play()).
- Write a function that dynamically increases geofence radius from 100m → 200m → 300m every 15s.
- Implement watchPosition with error handling and live location plotting on Google Maps.
- Build code that checks if user is inside any geofence from a list of multiple polygons.
- Write code to send entry/exit events to a mock API endpoint (/api/logs).
- Implement a geofence monitor that logs “Active” if user has at least one active geofence.
Advanced Questions
- Build a system that tracks Entry → Stay → Exit transitions and logs them in correct order.
- Implement multiple geofence manager where 3 polygons and 2 circles are active and tracked separately.
- Create Google Maps integration where user marker turns green inside, red outside geofence.
- Simulate a dashboard showing how many users are currently inside geofence (fake random coordinates).
- Implement stay detection for 5 simulated users, each with random movement paths.
- Write logic that triggers different API calls on transitions: /enter, /stay, /exit.
- Build a logging system that saves transition history to localStorage and renders a table UI.
- Implement polygon-based detection for a custom irregular zone (not a circle).
- Create a geofencing simulation that generates random paths and tests all Entry/Stay/Exit transitions.
- Develop a full geofencing solution with Google Maps: supports circles + polygons, logging, error handling, and stay detection.