Going to expand on this with a quick example:
Yes, if you want to implement the feature you described, you will need to create a map through the JavaScript API.
In order to draw on the map, you will need to define the lat
and lng
of EACH point of your shape on the map.
For the sake of example, I created a simple map which draws a square shape over Wyoming and Colorado, encapsulating the state in the highlighted area.
Here is the code approach. First, you need to define the bounds by marking the coordinates of your shape. I did this by creating the variables COborder
and WYborder
.
var COborder = [
{lat: 41.00244, lng: -102.05165},
{lat: 41.00056, lng: -109.05016},
{lat: 36.99909, lng: -109.04521},
{lat: 36.99295, lng: -102.04204},
]
var WYborder = [
{lat: 40.99752, lng: -111.04705},
{lat: 41.00477, lng: -104.05151},
{lat: 44.99831, lng: -104.057},
{lat: 45.0017, lng: -111.05255}
After your shapes are defined, you will want to display them on your map as a polygon.
map.data.add( {geometry: new google.maps.Data.Polygon([COborder])})
map.data.add( {geometry: new google.maps.Data.Polygon([WYborder])})
If you want to see a live example, I set up a JSFiddle here.