用OpenLayers 在地图上画简单的轨迹怎么画
1个回答
2015-04-17 · 知道合伙人数码行家
关注
展开全部
/使用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]);
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]);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询