vector-features.html の
「// create a line feature from a list of points」から
「// create a polygon feature from a linear ring of points」の前まで
をコピーして「ol010-nippon_bmi_akiruno_pgis.html」の次の位置に貼り付けます。
--- var point3 = new OpenLayers.Geometry.Point(139.270, 35.724).transform(epsg4326, map.getProjectionObject()); //緯度経度修正 var pointFeature3 = new OpenLayers.Feature.Vector(point3,null,style_mark); var point4 = new OpenLayers.Geometry.Point(139.270, 35.724).transform(epsg4326, map.getProjectionObject()); //緯度経度修正 var pointFeature4 = new OpenLayers.Feature.Vector(point4,null);
// create a line feature from a list of points var pointList = [point, point2, point3];
/* var newPoint = point; for(var p=0; p<15; ++p) { newPoint = new OpenLayers.Geometry.Point(newPoint.x + Math.random(1), newPoint.y + Math.random(1)); pointList.push(newPoint); } */
var lineFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.LineString(pointList),null,style_green);
map.addLayer(vectorLayer); // map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5); vectorLayer.addFeatures([pointFeature, pointFeature3, pointFeature2, pointFeature4, lineFeature]); //, polygonFeature]); ---
29-5 ポリゴン(面)の表示
単純なポリゴンを表示します。vector-features.html では、計算をしてポイントを作成していますが、29-3 で表示したポイントを使用します。
vector-features.html の
「// create a polygon feature from a linear ring of points」から
「map.addLayer(vectorLayer);」の前まで
をコピーして「ol010-nippon_bmi_akiruno_pgis.html」の次の位置に貼り付けます。
--- var lineFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.LineString(pointList),null,style_green);
// create a polygon feature from a linear ring of points /* var pointList = []; for(var p=0; p<6; ++p) { var a = p * (2 * Math.PI) / 7; var r = Math.random(1) + 1; var newPoint = new OpenLayers.Geometry.Point(point.x + (r * Math.cos(a)), point.y + (r * Math.sin(a))); pointList.push(newPoint); } */
pointList.push(pointList[0]);
var linearRing = new OpenLayers.Geometry.LinearRing(pointList); var polygonFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Polygon([linearRing]));
map.addLayer(vectorLayer); // map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5); vectorLayer.addFeatures([pointFeature, pointFeature3, pointFeature2, pointFeature4, lineFeature, polygonFeature]); ---
0 件のコメント:
コメントを投稿