Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.71 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  5.     <meta charset="utf-8">
  6.     <title>Simple Polygon</title>
  7.     <style>
  8.          /* Always set the map height explicitly to define the size of the div
  9.         * element that contains the map. */
  10.          #map {
  11.              height: 100%;
  12.          }
  13.          /* Optional: Makes the sample page fill the window. */
  14.          html, body {
  15.              height: 100%;
  16.              margin: 0;
  17.              padding: 0;
  18.          }
  19.     </style>
  20. </head>
  21. <body>
  22. <div id="map"></div>
  23.     <div id ="demo"></div>
  24. <script>
  25.  
  26.       // This example creates a simple polygon representing the Bermuda Triangle.
  27.  
  28.       function initMap() {
  29.         var map = new google.maps.Map(document.getElementById('map'), {
  30.           zoom: 5,
  31.           center: {lat: 24.886, lng: -70.268},
  32.           mapTypeId: 'terrain'
  33.         });
  34.  
  35.  
  36.  
  37.         var str = "46.602812499999985 41.543125 45.277187499999989 42.79 45.867812499999985 42.934375 46.602812499999985 41.543125";
  38.         var str1 = "47.602812499999985 42.543125 46.277187499999989 43.79 46.867812499999985 43.934375 47.602812499999985 42.543125";
  39.         var res = str.split(" ");
  40.         var res1 = str1.split(" ");
  41.         var points = [];
  42.           var points2 = [];
  43.         for (var i = 0; i < res.length; i += 2) {
  44.            points.push(new google.maps.LatLng(res[i], res[i + 1]));
  45.        }
  46.        for (var i = 0; i < res1.length; i += 2) {
  47.            points2.push(new google.maps.LatLng(res1[i], res1[i + 1]));
  48.        }
  49.        document.getElementById("demo").innerHTML = points;
  50.  
  51.  
  52.  
  53.        // Define the LatLng coordinates for the polygon's path.
  54.        var triangleCoords = [
  55.          {lat: 25.774, lng: -80.190},
  56.          {lat: 18.466, lng: -66.118},
  57.          {lat: 32.321, lng: -64.757},
  58.          {lat: 25.774, lng: -80.190}
  59.        ];
  60.        // Construct the polygon.
  61.        var bermudaTriangle = new google.maps.Polygon({
  62.          paths: points,
  63.          strokeColor: '#FF0000',
  64.          strokeOpacity: 0.8,
  65.          strokeWeight: 2,
  66.          fillColor: '#FF0000',
  67.          fillOpacity: 0.35
  68.        });
  69.        var bermudaTriangle1 = new google.maps.Polygon({
  70.            paths: points2,
  71.            strokeColor: '#FFAA00',
  72.            strokeOpacity: 0.8,
  73.            strokeWeight: 2,
  74.            fillColor: '#FFAAFF',
  75.            fillOpacity: 0.35
  76.        });
  77.        bermudaTriangle.setMap(map);
  78.          bermudaTriangle1.setMap(map);
  79.      }
  80.    </script>
  81.     <script async defer
  82.            src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCDE_ijBWEKPjRqgLzy6kSFR7DcBvTC1VM&callback=initMap">
  83.     </script>
  84. </body>
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement