I have an array containing latitude and longitude of different location which is displayed in the google map. Now I need to make a polygon passing through all these points.
Just take the example you took and add more points.
However, with more than three points, you'll have intersection trouble if you don't sort the coordinates properly.
To fix it you'll need an algorithm:
Here is the answer: Sorting points to avoid intersections.
You can stop at the second point of the answer, you just calculate the center of your polygon and then the angles to sort the points.
However, you can't use latitude and longitude with this algorithm.
For this scale you can just project your coordinates to a 2d plane.
Go for this: merkator projection