Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:13:40+00:00 2026-06-04T00:13:40+00:00

With the code below I can draw a polygon on a map, however the

  • 0

With the code below I can draw a polygon on a map, however the polygons are being treated as one and the api is joining them up as on polygon. I have been banging my head against this one! I need each polygon to load a different shape on the map. Which is formatted like this inside the array:

[[11.11,11.11],[22.22,22.22],[33.33,33.33]]

of

[[[11.11,11.11],[22.22,22.22],[33.33,33.33]],[[11.11,11.11],[22.22,22.22],[33.33,33.33]]]




var polys = [[[51.4503639, -0.1006082], [51.4502851, -0.1000704], [51.4491791, -0.0992159], [51.4480629, -0.0978004], [51.4486121, -0.098658], [51.4503639, -0.1006082]], [[51.4225526, -0.1618125], [51.42297, -0.160525], [51.4222314, -0.1603534], [51.421847, -0.1590405], [51.4216169, -0.1583023], [51.4198131, -0.1587487], [51.4196633, -0.1579333], [51.4195509, -0.1571436], [51.4188674, -0.1577788], [51.4190548, -0.1585427], [51.4189852, -0.1594954], [51.4182427, -0.1601064], [51.4175419, -0.1606966], [51.416929, -0.1618334], [51.4175821, -0.1618763], [51.4183207, -0.1624428], [51.4181762, -0.1640049], [51.4182297, -0.1646916], [51.4191932, -0.1649233], [51.4204705, -0.1644732], [51.4211931, -0.1643445], [51.4216213, -0.1642758], [51.4209897, -0.1643016], [51.4201781, -0.163241], [51.4214072, -0.1623876], [51.4219531, -0.1621987], [51.4220602, -0.1621558], [51.4225526, -0.1618125]]]

  var latLng =[]
  var locs = []

  for (var _p=0; _p < polys.length; _p++) {
      locs = polys[_p];

      for (_i = 0, _len = locs.length; _i < _len; _i++) {
          point = locs[_i];
          latLng.push(new google.maps.LatLng(point[0], point[1]));}

          bermudaTriangle = new google.maps.Polygon({
           paths: latLng,
           fillColor: "#FF0000",
           fillOpacity:0.1
           });
  }
          bermudaTriangle.setMap(map);


  }

In the end this worked:

  var latLng =[]
  var locs = []
  for (var _p=0; _p < polys.length; _p++) {
      locs = polys[_p];
      var  latLng = [];
      var bermudaTriangle = []
    for (_i = 0, _len = locs.length; _i < _len; _i++) {

            point = locs[_i];
            latLng.push(new google.maps.LatLng(point[0], point[1]));}


    bermudaTriangle = new google.maps.Polygon({
               paths: latLng,
               fillColor: "#FF0000",
               fillOpacity:0.1
    });

    bermudaTriangle.setMap(map);
     }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:13:41+00:00Added an answer on June 4, 2026 at 12:13 am

    You should move the call to create your Polygon outside of the inner loop. And you need to recreate the latLng array each time.

    var latLng =[];
    
    for (_i = 0, _len = locs.length; _i < _len; _i++) {
              point = locs[_i];
              latLng.push(new google.maps.LatLng(point[0], point[1]));}
    }
    
    bermudaTriangle = new google.maps.Polygon({
               paths: latLng,
               fillColor: "#FF0000",
               fillOpacity:0.1
    });
    
    bermudaTriangle.setMap(map);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I draw the ellipse with the code as shown below. How can I make
I have this code below. As you can see I am passing two variables
I can draw text using the below code, myCanvas.fillStyle = Red; myCanvas.font = 30pt
I am being able to draw the image using something like the code below:
In the code below I have two Canvas layers one text and one image,
I have the below code, which works, to draw a border around a control
I have to draw a bitmap image using DrawingContext.DrawImage method. Using the code below
It is a compiler error or runtime error? The code below can be compiled!
The simple code block below can be served up in a static HTML page
In past, I am using Listview and using below code can show a particular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.