How to divide a map into square grids?

A

AC Question

I want to fix 4 boundary points to a map and then divide that map into square grids of (say 1 km X 1 km ).
After dividing the map into grids into 1 km x 1 km square grids I wish to get the corner coordinates (the latitude and longitude values) of every single grid in order to determine if any user input (lat ,long) falls into a grid and if it does, which grid. The square grids have to be provided an index value in the form ( i , j ) where, i=x-axis coordinate , j=y-axis coordinate.
Eg. Suppose my location is (22.00009,76.00009) , after dividing the map into grids it falls under a square cell on the grid . The x,y axis have been numbered 1 to n (my grid is n X n region). Based on the lat, long provided by me I wish to extract which square grid doest it fall into (say (2,3) or (3,4)).

I was wondering if I could do that ?