- 浏览: 177552 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (163)
- POI (8)
- Collection容器 (1)
- java.util (2)
- java调用批处理 (1)
- xml (1)
- jfreechart (3)
- SVN (1)
- tomcat中文 (1)
- jquery (6)
- Log4j (1)
- ppt (1)
- js (48)
- ss (1)
- 综合 (1)
- Spring (2)
- 数据库 (6)
- tomcat (1)
- commons-lang包使用 (1)
- AJAX【Jquery】 (3)
- RMI (2)
- OpenLayers (25)
- html (20)
- css (25)
- Google地图 (2)
- java (1)
- Ibatis (1)
- GoogleMaps (1)
- J2EE (2)
- 软件设计 (1)
- 服务器 (1)
- html5 (4)
- cursor (1)
- AngularJs (5)
- 缓存 (1)
- 构建 (2)
- 域名、空间、服务器 (1)
<div class="iteye-blog-content-contain" style="font-size: 14px">
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!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>OpenLayer : Feature Select</title>
<link rel="stylesheet" href="<%=basePath%>/Script/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="<%=basePath%>/Style/style.css" type="text/css">
<script src="<%=basePath%>/Script/lib/OpenLayers.js"></script>
<script type="text/javascript">
var map = null;
var wms_url = "http://wms.jpl.nasa.gov/wms.cg";//http://wms.jpl.nasa.gov/wms.cg
var wms_version = "1.3.0";
var layer_name = 'country';
var wms_layer = null;
var vector_layer = null;
var select_control = null; // SelectFeature Control
var wkt_reader = null;
var point = "POINT(-10 -10)";
var line = "LINESTRING(-180 90, 0 0)";
var polygon = "POLYGON(0 0,0 90,180 90,180 0,0 0)";
function init()
{
//创建map对象,
map = new OpenLayers.Map("map");
wms_layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
wms_url,
{layers: layer_name, version: wms_version},
{singleTile: true});
vector_layer = new OpenLayers.Layer.Vector("Vector");
// 添加图层
map.addLayers([wms_layer, vector_layer]);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
// 在Vector图层上添加图元element
addFeature(point , vector_layer);
addFeature(line , vector_layer);
addFeature(polygon, vector_layer);
vector_layer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(20,20)));
addSelectControl(map, vector_layer);
// 放大到全屏
map.zoomToMaxExtent();
}
function addSelectControl(map, vector_layer)
{
if(select_control!=null)
{
return ;
}
select_control = new OpenLayers.Control.SelectFeature(vector_layer,
{
hover: false,
onSelect: onFeatureSelect,
onUnselect: onFeatureUnselect
});
map.addControl(select_control);
select_control.activate();
}
function addFeature(wkt, layer)
{
var geometry = toGeometryFromWkt(wkt);
if(wkt!=null)
{
layer.addFeatures(geometry);//geometry:OpenLayers.Feature.Vector类型
}
}
function toGeometryFromWkt(wkt)
{
var geometry = null;
if(wkt_reader==null)
{
wkt_reader = new OpenLayers.Format.WKT();
}
geometry = wkt_reader.read(wkt);//read方法返回OpenLayers.Feature.Vector类型
return geometry;
}
// Feature 选中事件响应
function onFeatureSelect(feature)
{
selectedFeature = feature;
//feature代表Openlayers.Layer.Vector类型的对象,可以理解为一张画布
//feature.geometry可以是:Point,line,polygon等几何图形的父类
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
null,
"<div style='font-size:.8em'>Feature: " + feature.id+"<br/>点的lon: "
+ feature.geometry.x+",点的lat: "+feature.geometry.y+"<br/>"+"<br />Area: "
+ feature.geometry.getArea()+"<br>lat: "+feature.geometry.bounds.centerLonLat.lat+",lon: "
+ feature.geometry.bounds.centerLonLat.lon+"</div>",
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
}
// Feature取消选中事件响应
function onFeatureUnselect(feature)
{
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
function onPopupClose(evt) {
select_control.unselect(selectedFeature);
}
</script>
</HEAD>
<BODY onload="init()">
<div>
<div id="map" class="smallmap"></div>
</div>
</BODY>
</HTML>
</div>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!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>OpenLayer : Feature Select</title>
<link rel="stylesheet" href="<%=basePath%>/Script/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="<%=basePath%>/Style/style.css" type="text/css">
<script src="<%=basePath%>/Script/lib/OpenLayers.js"></script>
<script type="text/javascript">
var map = null;
var wms_url = "http://wms.jpl.nasa.gov/wms.cg";//http://wms.jpl.nasa.gov/wms.cg
var wms_version = "1.3.0";
var layer_name = 'country';
var wms_layer = null;
var vector_layer = null;
var select_control = null; // SelectFeature Control
var wkt_reader = null;
var point = "POINT(-10 -10)";
var line = "LINESTRING(-180 90, 0 0)";
var polygon = "POLYGON(0 0,0 90,180 90,180 0,0 0)";
function init()
{
//创建map对象,
map = new OpenLayers.Map("map");
wms_layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
wms_url,
{layers: layer_name, version: wms_version},
{singleTile: true});
vector_layer = new OpenLayers.Layer.Vector("Vector");
// 添加图层
map.addLayers([wms_layer, vector_layer]);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
// 在Vector图层上添加图元element
addFeature(point , vector_layer);
addFeature(line , vector_layer);
addFeature(polygon, vector_layer);
vector_layer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(20,20)));
addSelectControl(map, vector_layer);
// 放大到全屏
map.zoomToMaxExtent();
}
function addSelectControl(map, vector_layer)
{
if(select_control!=null)
{
return ;
}
select_control = new OpenLayers.Control.SelectFeature(vector_layer,
{
hover: false,
onSelect: onFeatureSelect,
onUnselect: onFeatureUnselect
});
map.addControl(select_control);
select_control.activate();
}
function addFeature(wkt, layer)
{
var geometry = toGeometryFromWkt(wkt);
if(wkt!=null)
{
layer.addFeatures(geometry);//geometry:OpenLayers.Feature.Vector类型
}
}
function toGeometryFromWkt(wkt)
{
var geometry = null;
if(wkt_reader==null)
{
wkt_reader = new OpenLayers.Format.WKT();
}
geometry = wkt_reader.read(wkt);//read方法返回OpenLayers.Feature.Vector类型
return geometry;
}
// Feature 选中事件响应
function onFeatureSelect(feature)
{
selectedFeature = feature;
//feature代表Openlayers.Layer.Vector类型的对象,可以理解为一张画布
//feature.geometry可以是:Point,line,polygon等几何图形的父类
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
null,
"<div style='font-size:.8em'>Feature: " + feature.id+"<br/>点的lon: "
+ feature.geometry.x+",点的lat: "+feature.geometry.y+"<br/>"+"<br />Area: "
+ feature.geometry.getArea()+"<br>lat: "+feature.geometry.bounds.centerLonLat.lat+",lon: "
+ feature.geometry.bounds.centerLonLat.lon+"</div>",
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
}
// Feature取消选中事件响应
function onFeatureUnselect(feature)
{
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
function onPopupClose(evt) {
select_control.unselect(selectedFeature);
}
</script>
</HEAD>
<BODY onload="init()">
<div>
<div id="map" class="smallmap"></div>
</div>
</BODY>
</HTML>
</div>
发表评论
-
Opanlayers用LineString画多边形
2014-09-24 00:26 1344<!DOCTYPE html> <htm ... -
OpenLayers地图联动
2014-09-23 22:27 1011地图联动 -
OpenLayers 选中元素弹框
2014-05-25 23:26 2459写道 http://www.openlayers.org ... -
困扰我的关于OpenLayers的问题终于解决了:
2014-04-15 13:45 1697原因: 添加标记的时候需要加上中扩号-> map.ad ... -
OpenLayers结合Googlemaps中的Tips
2014-04-01 21:29 1387<%@ page language="ja ... -
改变OpenLayers缩放工具条位置以及大小
2014-03-25 23:49 1614<script type="text/ ... -
geometry类和feature类
2013-10-17 02:14 1359我们上面的章节一直使用的都是feature,但是featur ... -
OpenLayers基底图层和叠加图层区别
2013-10-17 00:24 4911OpenLayers有多个不同的图层类,每一个都可以连接到不同 ... -
OpenLeyers矢量图层及矢量元素整合操作
2013-10-14 00:43 1684<%@ page language="java ... -
设置地图缩放控件位置
2013-10-13 22:53 1046map.addControl(new OpenLayers.C ... -
控制地图与div的占据区域【目标:让地图默认占满展现区】
2013-10-13 22:48 1074方法: 设置map的options,由其中两个因 ... -
创建OpenLayers地图步骤
2013-10-13 10:51 1358为地图添加绘制点、线、面步骤: 1、无可厚非对地图进行操作 ... -
获取OpenLayers画图控件画过的图形顶点
2013-10-13 04:18 1879在你使用画图工具画图的时候,画的图会作为你的vlayer的一个 ... -
包含多个图层、缩放条、工具条、鼠标位置、弹出窗口
2015-04-10 01:09 1537<style type="text/css ... -
OpenLayers例子解析
2013-09-22 01:26 3196抽点时间从OpenLayers官方网站上找些例子具体解释一下M ... -
鼠标点击添加标记
2013-09-22 00:58 2081//点击一个标注按钮的事件,该方法的作用就是启用添加标注事件 ... -
Maker-shadow
2013-09-22 00:30 901<%@ page language="jav ... -
Marker(mousedown)
2013-09-22 00:29 957<%@ page language="jav ... -
OpenLayers>Marker>events(click/mousedown)【地图中标记的事件】
2013-09-22 00:19 2106<%@ page language="jav ... -
OpenLayers创建地图
2015-04-10 01:09 650<html> <head> <m ...
相关推荐
- WFS服务:用于获取矢量数据,通过`OpenLayers.Layer.Vector.WFS`类创建。 - GeoJSON数据:使用`OpenLayers.Format.GeoJSON`解析并加载到`OpenLayers.Layer.Vector`层。 4. **图层操作** - 添加图层:`map.add...
var marker = new OpenLayers.Feature.Vector(points[index]); vectorLayer.addFeatures([marker]); if (index > 0) { vectorLayer.removeFeatures([lastMarker]); } lastMarker = marker; index++; } else ...
在OpenLayers中,删除Layer中的marker可以通过以下步骤实现:首先,获取到你想要删除的marker对象,这通常基于用户交互事件(如点击)来完成。然后,调用Layer的removeFeatures方法,传入marker对象即可将其从地图上...
### Openlayer 简单实例11:添加Vector图层及测量功能 #### 一、OpenLayers简介 OpenLayers是一款开源的JavaScript库,用于显示基于矢量数据的地图和其他类型的地理信息。它支持多种数据源,如WMS(Web Map ...
var vectorLayer = new OpenLayers.Layer.Vector("Editable Layer"); var modifyControl = new OpenLayers.Control.ModifyFeature(vectorLayer); map.addLayers([vectorLayer]); map.addControl(modifyControl);...
`OpenLayers.Layer.Vector`用于展示这些矢量特征,支持动态绘制、编辑和查询。 7. **事件处理(Events)** - OpenLayers 提供了丰富的事件处理机制,如mapMove、featureSelect等,允许开发者响应用户的交互行为。 ...
var locationLayer = new ol.layer.Vector({ source: new ol.source.Vector(), style: new ol.style.Style({ image: new ol.style.Circle({ fill: new ol.style.Fill({ color: '#ffcc33' }), stroke: new ol....
var vector = new OpenLayers.Layer.Vector("EditableVectors"); map.addLayers([vector]); map.addControl(new OpenLayers.Control.EditingToolbar(vector)); ``` - **Geolocate(地理定位)**:将W3C地理位置...
`OpenLayers.Layer.Vector`类用于创建矢量图层,`OpenLayers.Geometry`类则提供了几何对象的构建。 7. WFS服务:OpenLayers可以与Web Feature Service (WFS)交互,用于读取和编辑地理空间数据。`OpenLayers....
为了将这个功能集成到你的应用中,你需要一个矢量图层(`ol.layer.Vector`)和一个矢量源(`ol.source.Vector`),并将`addMarker`函数调用多次以添加多个标记: ```javascript var vectorSource = new ol.source....
在OpenLayers 3中,热力图通常使用`ol.source.Heatmap`源和`ol.layer.Heatmap`层来实现。下面我们将深入探讨如何使用OpenLayers 3创建热力图以及涉及的相关知识点。 首先,你需要准备包含地理位置信息的数据,这...
vlayer = new OpenLayers.Layer.Vector("控件层"); map.addLayer(vlayer); ``` 接着,我们创建一个Control.Panel,用于添加测距和测面积的控件。这两个控件分别基于OpenLayers.Handler.Path和OpenLayers.Handler....
例如,使用`OpenLayers.Geometry.Point()`创建一个点对象,然后通过`OpenLayers.Feature.Vector()`将其封装为特征,最后加入到图层中。 6. **事件处理**: 开发者可以监听地图上的各种事件,如点击、移动、缩放等...
首先,我们需要理解OpenLayers中的矢量图层(Vector Layer)和几何对象(Geometry)。矢量图层用于显示由点、线、面等几何对象组成的地理数据。在态势箭头或进击箭头的场景中,我们可以使用LineString几何对象来表示...
var feature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point(dataPoints[i].lon, dataPoints[i].lat), {weight: dataPoints[i].weight} ); vectorLayer.addFeatures([feature]); } // 定义...
5. **标记(Feature和Vector Layer)**:`OpenLayers.Feature`和`OpenLayers.Vector`用于在地图上添加点、线、面等矢量数据。这些标记可以具有样式、属性,并可以通过图层进行操作。 6. **事件(Event)**:OpenLayers...
var vectorLayer = new OpenLayers.Layer.Vector("Vector Layer"); map.addLayer(vectorLayer); ``` 3. **设置中心点和缩放级别**: ```javascript map.setCenter(new OpenLayers.LonLat(-122.45, 37.75), 13);...
1. **绘制点**:OpenLayers 提供了 `ol.source.Vector` 和 `ol.layer.Vector` 类来处理矢量数据。开发者可以创建一个新的 `ol.geom.Point` 对象,然后将其添加到矢量源,最后将矢量源添加到矢量图层。点的坐标通常以...