View this example full screen.
function initialize() { var mapOptions = { zoom: 1, center: new google.maps.LatLng(24.886, -70.268), mapTypeId: google.maps.MapTypeId.TERRAIN }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var redCoords = [ new google.maps.LatLng(25.774, -80.190), new google.maps.LatLng(18.466, -66.118), new google.maps.LatLng(32.321, -64.757) ]; var blueCoords = [ new google.maps.LatLng(25.774, -60.190), new google.maps.LatLng(18.466, -46.118), new google.maps.LatLng(32.321, -44.757) ]; // Construct the red polygon new google.maps.Polygon({ map: map, paths: redCoords, strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.35, draggable: true, geodesic: true }); // Construct the blue polygon new google.maps.Polygon({ map: map, paths: blueCoords, strokeColor: '#0000FF', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#0000FF', fillOpacity: 0.35, draggable: true, geodesic: false }); } google.maps.event.addDomListener(window, 'load', initialize);
<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <title>Draggable polygons</title> <link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet"> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script> function initialize() { var mapOptions = { zoom: 1, center: new google.maps.LatLng(24.886, -70.268), mapTypeId: google.maps.MapTypeId.TERRAIN }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var redCoords = [ new google.maps.LatLng(25.774, -80.190), new google.maps.LatLng(18.466, -66.118), new google.maps.LatLng(32.321, -64.757) ]; var blueCoords = [ new google.maps.LatLng(25.774, -60.190), new google.maps.LatLng(18.466, -46.118), new google.maps.LatLng(32.321, -44.757) ]; // Construct the red polygon new google.maps.Polygon({ map: map, paths: redCoords, strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.35, draggable: true, geodesic: true }); // Construct the blue polygon new google.maps.Polygon({ map: map, paths: blueCoords, strokeColor: '#0000FF', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#0000FF', fillOpacity: 0.35, draggable: true, geodesic: false }); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> </html>