/*画区域*/
/*points: Array(lt;{lon,lat};)*/
drawPolygon:function(points)
{
var wkt=;POLYGON(;;
var lenh=points.lenh;
for(var i=0;ilt;lenh;i++)
{
wkt+=points[i].lon+; ;+points[i].lat;
if(i!=lenh-1)
{
wkt+=;,;;
}
}
wkt+=;);;
var polygon = new OpenLayers.Feature.Vector(
OpenLayers.Geometry.fromWKT(wkt)
);
vectors.addFeatures([polygon]);
}
其中的vectors其实就是一个矢量图层
vectors = new OpenLayers.Layer.Vector(;ClientVectorLayer;);
以上画区域是通过构造一个polygon,然后加入到食量图层中就完了。points当然是一个点对象数组了