用OpenLayers 在地图上画简单的轨迹怎么画
发布网友
发布时间:2022-04-14 21:04
我来回答
共1个回答
热心网友
时间:2022-04-14 22:34
/使用OpenLayers.Layer.Vector,map要先建立
var vectors,lineFeature;//存放线路
//线路样式
var style_green = {
strokeColor: "#00FF00",
strokeWidth: 3,
strokeDashstyle: "dashdot",
pointRadius: 6,
pointerEvents: "visiblePainted"
};
//画线图层设置
var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
layer_style.fillOpacity = 0.2;
layer_style.graphicOpacity = 1;
//画线图层
vectors = new OpenLayers.Layer.Vector("Simple Geometry", {style: layer_style});
map.addLayer(vectors);
//一下采用数组型式填充轨迹
var pointList = [];
for(var i=0;i<5;i++){
newPoint = new OpenLayers.Geometry.Point(lon,lan);
pointList.push(newPoint);
}
lineFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(pointList),null,style_green);
vectors.addFeatures([lineFeature]);