Geofencing is actually a process of creating/defining geofence on the maps. It can be either circle,rectangle or n-sided polygon shaped. Geofence is nothing but a virtual boundary that is drawn on map. Geofence have many applications like:

  1. If a vehicle moves out of a specified area(geofence) then we can send an alert to the owner of the vehicle.
  2. If a prisoner tied with a gps device tries to leave the premises then security people can be alerted.

How it works ?

The gps device regularly sends the lat-long coordinates which we can examine to see if it falls inside/outside the geofence boundary and then take appropriate action accordingly.

How to create geofence ? 

Google Maps API provides geofence objects:

Here we are drawing a rectangle shaped geofence using some properties like fillColor,opacity etc.

It looks something like this:

A rectangle geofence boundary is determined by north-east and south-west coordinates.  So if we want to check an incoming gps coordinates against the geofence we could do so using the following pseudo-code:

That was all folks!