This way it is also fairly easy to identify a rectangle by for example it's top left will always be located on the same position. Note, you only draw those grid lines which are within map's view of bounds. So how do you know where to draw the grid lines? If you decide on a standard zero point (for instance the point where the equator and prime Meridian meet), and basically start drawing grid lines from there, you will always have the grid lines (and thus rectangles) positioned on the same location.
![grid mapping on google my maps grid mapping on google my maps](https://i.stack.imgur.com/x2nc2.png)
If you know where to draw the grid, you also know where to draw the rectangles since the edges of the rectangles are basically line segments of the grid lines. Or you could use the coordinates of the mouse click on the map to identify which square was clicked. You can bind 'click' events to these rectangles, such that you can interact with them. If you also would like to draw the rectangles with events bound to them (as in your example), you can use a Rectangle with certain options.Draw the grid in the shape of PolyLines, which allow for a few options to be set, like for instance color and width.Use this distance to determine how many lines (with distance of 1km) you should draw.
![grid mapping on google my maps grid mapping on google my maps](https://roamingtheamericas.com/wp-content/uploads/2017/07/29-2466-pp_gallery/Google-My-Maps-selected-layer(pp_w692_h335).jpg)
GRID MAPPING ON GOOGLE MY MAPS FREE
A free conversion service developed and hosted by Grid Atlas.
![grid mapping on google my maps grid mapping on google my maps](https://monde-geospatial.com/wp-content/uploads/2017/12/google-map-overlay-for-google-ea.jpg)
Find the bounds of the map using the getBounds() method of the Map object.The answer to your question can be found in the Google Maps API (v3).