Google Maps Api Changing a polygon to a circle

2019-06-13 06:01发布

问题:

I have some code with points which draws a polygon.

Here is the code:

  app.pts = [
    [33.644631, -70.610453],
    [33.637884, -70.608253],
    [33.637566, -70.608704],
    [33.638933, -70.610935],
    [33.641044, -70.614036],
    [33.641386, -70.614176]
 ];

 app.map = L.map('map').setView(app.pt, 15);


 app.polygon = L.polygon(app.pts, {
    color: '#00ff00',
    opacity: 0.6,
    fillOpacity: 0.2
 });

What I would like is a circle instead, so my question is:

How do I modify this code so I can draw a Circle instead of a polygon?

The circle would be 50 meters radius and centered on 33.644631, -70.610453

回答1:

Per the documentation

app.circle = L.circle([33.644631, -70.610453], {radius: 50});