بسم الله الرحمن الرحيم
In the name of Allah, the Most Gracious, the Most Merciful
During my work on a project, I was asked to add an overlay for Al-Baha province in the Kingdom of Saudi Arabia. I remembered fulfilling the same request in another project about 4 years ago and the long search for the border coordinates. I found a KML file with coordinates on a website which provides a KML files for countries, states and regions borders and converted them to latitude and longitude, then added them to the map as an overlay.
// const contains lat/lng coordinates
const overlayPath = [{lat:20.40994682,lng:42.11893877},{lat:20.40954332,lng:42.11729597},...];
// Create overlay from coordinates + adding style
const Overlay = new google.maps.Polygon({
paths: overlayPath,
strokeColor: "#0099dd",
strokeOpacity: 0.9,
strokeWeight: 2,
fillColor: "#0099dd",
fillOpacity: 0.3,
});
// Applying overlay to your map instance
Overlay.setMap(mapInstance);