我们上面的章节一直使用的都是feature,但是feature,中有个非常重要的属性就是geometry对象,他保存着对象的事件形态,就是我们vectorLayer上
显示的几何图形。
eg 我们要创建一个Feautre,里面会包装一个Feature
var feature_point = new OpenLayers.Feature.Vector({new OpenLayers.Geometry.Point(lon,lat)})
几何类的方法
atPoint(lonlat,tolerancelon,tolerancelat) 参数lonlat为OpenLayers.LonLat,后面的两个参数为点的阈值,因为feature在地图是以带style的点。
calculateBounds() 重新计算集合的边界,但是不返回任何值
clearBounds(): 把geometry的边界设为null
clone(): 复制一个OpenLayers.Geometry对象
destroy() 销毁一个geometry,但是如果这个geometry是feature的一部分,销毁会失败
distanceTo (geometry, options) 这个方法会返回自己与最近或是传入geometry之间距离,options有个属性,distance如果为true将会返回
包含x0y0,x1y1和距离的对象,为false的话,会返回距离数,但是要注意map的units设置的单位
extendBounds(bounds) 不是很明白
getArea() 返回一个{Float},包含这个geometry的面积
getBounds() 返回{openLayers.Bounds}对象
getCentroid() 返回geometry的中心点,{OpenLayers.Geometry.Point}对象
getLength() 返回一个geometry覆盖的长度{Flot}
getVertices(nodes) 返回geometry中所有的节点对象
toString() 返回wkt几何描述文本
Geometry 子类
Geometry.Point:包含(x,y)的对象
var my_point = new OpenLayers.Geometry.Point(-50,42);
Geometry.Collection:这是一个集合类,里面存放着Geometry的对象。LineString就是继承这个类。同几何对象的数组实例化。
var geom_collection = new OpenLayers.Geometry.Collection([geometry_point,geometry_line]);
Geometry.MultiPoint:这是一个点的几何对象,LineString就是继承的这个类,传递实例化对象的数组
var geom_multipoint = new OpenLayers.Geometry.MultiPoint([point1,point2])
Geometry.Curve: 曲线
Geometry.LineString:由点连接形成线,不能少于两个点的线
var geom_multi_line = new OpenLayers.Geometry.LineString([point1,point2]):
Geometry.MultiLineString::多线,不能少于两根线
var geom_multiLineString = new OpenLayers.Geometry.MultiLineString([line1,line2]);
Geometry.LinearRing:这是一个闭合的线对象,在几何上表达就是第一点,也是最后一点。
var geom_linear_ring = new OpenLayers.Geometry.linearRing([point1,point2,point3,point1])
Geometry.Polygon:这个类是一个Geometry.LinearRing的数组。
var geo_polygon = new OpenLayers.Geometry.Polygeo([linear1,linear2,linear3])
Geometry.MultiPolygon:是Geometry.polygon的数组
Geometry子类的方法
每个子类都有自己特有的方法或者是实现,我们可以参考开发文档。
Feature类
它一个有Geometry,和自身属性加上Style组成的类
方法
destroy(),销毁一个Feature Object
clone() 复制一个feature
getVisibility() 返回{boolean},feature是否可见
move(location) ,移动,可以传入OpenLayers.LonLat 和 OpenLayers.Pixel
onScreen(boundsOnly) 不是很清楚
使用SectFeature Control 与地图交互
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> < html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" >
< title >地图交互</ title >
< script type = "text/javascript" src = "OpenLayers.debug.js" ></ script >
< script type = "text/javascript" >
var map;
var vector_layer;
function init() {
//创建地图
map = new OpenLayers.Map('map');
//创建wms图层
var wms_layer = new OpenLayers.Layer.WMS('OpenLayers WMS',
layers : 'basic'
}, {});
//map.addLayer(wms_layer);
//创建矢量图层
vector_layer = new OpenLayers.Layer.Vector('Basic Vector Layer');
// map.addLayer(vector_layer);
map.addLayers([wms_layer,vector_layer]);
//创建并添加feature
var feature_point_1 = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(6.055, 46.234), {
'location' : 'Cern',
'description' : "Stand back, I'm going to try science!"
});
var feature_point_2 = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(-129, 3), {
'location' : 'The Sea',
'description' : 'Here be dragons'
});
var feature_polygon = new OpenLayers.Feature.Vector(
//We'll make a polgon from a linear ring object, which consists of points
new OpenLayers.Geometry.Polygon(new OpenLayers.Geometry.LinearRing([
new OpenLayers.Geometry.Point(-124.2, 41.9),
new OpenLayers.Geometry.Point(-120.1, 41.9),
new OpenLayers.Geometry.Point(-120, 39),
new OpenLayers.Geometry.Point(-114.5, 34.9),
new OpenLayers.Geometry.Point(-114.7, 32.7),
new OpenLayers.Geometry.Point(-117.1, 32.5),
new OpenLayers.Geometry.Point(-120, 34),
new OpenLayers.Geometry.Point(-123.7, 38.4)
//We won't pass in the first point, the polygon will close automatically
])), {
'location' : 'Fanghorn Forest',
'description' : 'Land of the Ents'
});
vector_layer.addFeatures([ feature_point_1, feature_point_2,
feature_polygon ]);
//创建并添加 selectFeature control
var select_feature_control = new OpenLayers.Control.SelectFeature(
vector_layer, {
multiple : false,
toggle : true,
toggleKey : 'ctrlKey',
multipleKey : 'shiftKey'
});
map.addControl(select_feature_control);
//激活控件
select_feature_control.activate();
//注册事件
vector_layer.events.register('featureselected', this, selected_feature);
vector_layer.events.register('featureunselected', this,unselected_feature);
if (!map.getCenter()) {
map.zoomToMaxExtent();
}
}
//触发选中事件
function selected_feature(event) {
//clear out the log's contents
document.getElementById('map_feature_log').innerHTML = '';
//Show the current selected feature (passed in from the event object)
var display_text = 'Clicked on: ' + '< strong >'
+ event.feature.attributes.location + '</ strong >' + ': '
+ event.feature.attributes.description + '< hr />';
document.getElementById('map_feature_log').innerHTML = display_text;
//Show all the selected features
document.getElementById('map_feature_log').innerHTML += 'All selected features: ';
//Now, loop through the selected feature array
for ( var i = 0; i < vector_layer.selectedFeatures.length; i++) {
document.getElementById('map_feature_log').innerHTML += vector_layer.selectedFeatures[i].attributes.location
+ ' | ';
}
}
//没有被选中
function unselected_feature(event) {
var display_text = event.feature.attributes.location + ' unselected!'
+ '< hr />';
document.getElementById('map_feature_log').innerHTML = display_text;
//Show all the selected features
document.getElementById('map_feature_log').innerHTML += 'All selected features: ';
//Now, loop through the selected feature array
for ( var i = 0; i < vector_layer.selectedFeatures.length; i++) {
document.getElementById('map_feature_log').innerHTML += vector_layer.selectedFeatures[i].attributes.location
+ ' | ';
}
}
</ script >
</ head >
< body onload = "init()" >
< div id = "map" style = "width: 500px; height: 500px;" ></ div >
< div id = "map_feature_log" >显示详情</ div >
</ body >
</ html >
|
相关推荐
第 06 节_GEE 的数据类型(Geometry,Feature, Feature Collection).pdf
echart地图全国344区县的基础数据,百度已停止下载。...如:{"type": "FeatureCollection", "features": [{"type":"Feature","properties":{"name":"洪湖市"},"geometry":{"type":"MultiPolygon","coordinates
We present a new technique for extracting line-type features on point-sampled geometry. Given an unstructured point cloud as input, our method first applies principal component analysis on local ...
Moving Trend and Geometry (3DMTG) property is proposed for human action recognition. Specifically, a histogram of 3D moving directions between consecutive frames for each joint is constructed to ...
featureCursor = featureLayer.FeatureClass.Search(null, false); feature = featureCursor.NextFeature(); ISpatialFilter spatialFilter = new SpatialFilterClass(); IFeatureSelection featureSelection; ...
algorithms have proven to be very reliable on certain classes of geometry. While it is always worth pursuing general algorithms viable on more general geometry, a combination of the
POPUP_MESSAGE Edits the selected feature by rolling back to the model state prior to the feature. ACTIONS STANDARD BUTTON/FOLDED UG_MODELING_EDIT_FEATURE_POSITION LABEL Edit P&ositioning... ...
{ "type": "Feature", "properties": { "PathName": "安固东路", "PathPY": "An Gu Dong Lu" }, "geometry": null }, { "type": "Feature", "properties": { "PathName": "安固中路", "PathPY": "An Gu Zhong Lu" },...
"type" : "Feature" , "properties" : { "fill" : "#0f0" } , "geometry" : { "type" : "Polygon" , "coordinates" : [ [ [ - 122.801742 , 45.48565 ] , [ - 122.801742 , 45.60491 ] , [ - 122.5847
"Multi-View Optimization of Local Feature Geometry". M. Dusmanu, J.L. Schönberger, and M. Pollefeys. European Conference on Computer Vision 2020 (Oral). 要求 C ++ 在继续之前,应将安装为库。 请...
除个人地理数据库要素类和表之外,查询表达式中的字符串是区分字母大小写的。如果搜索不需要区分大小写,可以使用SQL函数将所有的值都转换成大写或者小写。对于基于文件的数据源,例如shape文件或coverages,既可以...
TransFORMer ...Replaces the geometry of the feature with a two-dimensional arc whose shape is set by the parameters, which can be either constant floating point values or the values of existing
您将需要使用序列化JSON中包含的其他属性来扩展现有的Geometries,Feature和FeatureCollection类。 用法 例子1 给定一些GeoJSON数据,例如: { " type " : " Feature " , " geometry " : { " type " : " Point...
Java矢量磁贴 根据块矢量图块的Java编码器和解码器 ... addFeature( " road " , attributes, geometry); // Finally, get the byte array byte [] encoded = encoder . encode(); 或者,指定功能部件ID: VectorT
org.geotools.geometry.jts.spatialschema.geometry.geometry org.geotools.geometry.jts.spatialschema.geometry.primitive org.geotools.geometry.text org.geotools.gml org.geotools.gml.producer org.geo...
这是使用ffmpeg和montage(来自ImageMagick)创建图像精灵的一种方法: ffmpeg -i "video-name.mp4" -f image2 -vf fps=fps=1/5 video-name-d.jpgmontage video-name*jpg -tile 5x -geometry 150x video-name-...
4. 选择geometry的样式 11 16. 添加一个加载图片的自定义标签工具(已完成) 12 17. 比例尺和标签修饰(已完成) 13 18. 使用专题和图例 13 19. 相对路径加载地图 14 20. SearchInfoFactory类 15 21. 可制图表的一个...
"type": "Feature", "properties": {}, "geometry": { "type": "LineString", "coordinates": [ [ 0,0 ], [ 0,1 ], [ 1,1 ], [ 1,0 ] ] } }; var polyFeature = lineToPolygon(lineFeature); 返回: { ...
Applying geometry preserving linear- and non-linear manifold learning methods, the structure of the high-dimensional feature space is mapped to a two-dimensional representa- tion, which can be ...