I trying to write an automation script using an in-house built framework (Ginger and cucumber). We have an Angular JS application, I’m trying to interact with google maps and draw a polygon on the map. Can someone assist in how I can achieve that? (Note: Since it’s work-related, I can not provide specific but try my best in explaining.) - Thank you
Hello @harsh.s.bhardwaj!
I did some Google Maps programming a while back. This is a straight java script example.
The idea is to define the endpoints as coordinates of a polygon in an array, and provide that array to the Google Maps polygon object upon creation.
//triangle
var myPolygonEndpoints = [ {latitude1, longitude1},{latitude2, longitude2},{latitude3, longitude3}];
//create a filled triangle with blue border
var myPolygon = new google.maps.Polygon({
paths: myPolygonEndpoints,
strokeColor: ‘blue’,
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: ‘lightblue’,
fillOpacity: 0.25
});
//add it to the map
myPolygon.setMap(map);
The argument for setMap is the Google Maps object created when the page initializes.
When I was working in Google Maps, I found the documentation very useful. Google has this example for a polygon.
Joe