leaftlet 中Polygon的使用属性

绘制一个面

var latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]];

var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);

map.fitBounds(polygon.getBounds());

 

绘制环

var latlngs = [ [

// first polygon

[[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring

[[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole ],

[ // second polygon

[[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]] ] ];

var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);

map.fitBounds(polygon.getBounds());

 

// add a polygon

var polygon = L.polygon(

[ [36, 121], [37, 121], [36.5, 122], [36.5, 122.2] ],

{

color: 'green',

fillColor: '#f03',

fillOpacity: 0.5

}).addTo(m);

  • color 表示边框颜色
  • fillColor 表示填充颜色
  • fillOpacity 表示透明度

你可能感兴趣的:(Polygon,Polygon)