打开图层点事件
Open Layers point event
是否有人有如何使用事件处理程序与开放层点的例子?
感谢 function mapCreate(lon,lat){
map = new OpenLayers.Map("map1");
var osm = new OpenLayers.Layer.OSM();
vectors = new OpenLayers.Layer.Vector("Vector Layer");
map.addLayer(osm);
var center = new OpenLayers.LonLat(lon,lat).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
point = new OpenLayers.Geometry.Point(center.lon,center.lat);
vectors.addFeatures([new OpenLayers.Feature.Vector(point)]);
drag = new OpenLayers.Control.DragFeature(vectors);
//map.addLayer(vectors);
map.addControl(drag);
drag.activate();
map.setCenter(center, 15);
map.addLayer(vectors);
point.events.register('moveend',point, function(evt){
alert('hello');
});
}
这是我尝试过的一个例子,由于某种原因,这部分不工作
point.events.register('moveend',point, function(evt){
alert('hello');
});
这里有一些类似的代码,我在过去使用它来在页面右侧的div列表上显示悬停标记。包括它是因为它展示了我过去是如何处理这些点的。我认为这不是你想要的。
/* Included for per-item hovering from the paginated layer. */
function onFeatureSelected(event) {
hoveredItem = $(this).attr('lookup');
/* Do something here to indicate the onhover */
// find the layer pagination id
var feature = findFeatureById(hoveredItem);
if (feature) {
// use the pagination id to find the event, and then trigger the click for that event to show the popup
// also, pass a null event, since we don't necessarily have one.
feature.marker.events.listeners.click[0].func.call(feature, event)
}
}
function onFeatureUnselected(event) {
/* Do something here to indicate the onhover */
// find the layer pagination id
var feature = findFeatureById(hoveredItem);
if (feature) {
// use the pagination id to find the event, and then trigger the click for that event to show the popup
// also, pass a null event, since we don't necessarily have one.
feature.marker.events.listeners.click[0].func.call(feature, event)
}
/* Do something here to stop the indication of the onhover */
hoveredItem = null;
}
function findFeatureById(featureId) {
for (var key in map.layers) {
var layer = map.layers[key];
if (layer.hasOwnProperty('features')) {
for (var key1 in layer.features) {
var feature = layer.features[key1];
if (feature.hasOwnProperty('id') && feature.id == featureId) {
return feature;
}
}
}
}
return null;
}
如果你想添加这个点,因为它正在创建,我将不得不刷新我的记忆在过去是如何完成的。另外,GIS SE应该对您有帮助。
相关文章:
- 更改图层中单个矢量特征的图标
- 谷歌地图热图图层点半径
- 谷歌地图-更改图层图标大小
- 如何通过ID获取图层对象
- CS5隐藏图层的速度非常慢
- 开放图层导出为 KML 并保留我的地图样式
- 传单问题:使折线的图层组不可单击
- 将图层添加到另一个图层
- 图层删除(图像);在 Kinetic.js 中不起作用
- HTML5 Canvas 的初学者,使用图层
- 如何在“控制缩放”下的“打开图层”上添加一些图像
- 无法让 jQuery floatThead 处理嵌入在选项卡式图层中的表
- 如何在开放层 3 中设置矢量图层选择的样式
- 添加支持异步重新加载的 Web 图层
- 如何仅针对单击的图层触发单击事件,而不为其父层触发单击事件
- 切片图层加载开始和结束时的传单火灾事件
- 在zIndex较低的图层上,谷歌地图点击事件
- 图层二Canvas'在彼此的顶部+单击事件
- 打开图层点事件
- 当图层控件移出贴图元素时,不会发出传单贴图单击事件