2
有没有人有如何使用具有开放图层点的事件处理程序的示例?打开图层点事件
感谢
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');
});
感谢代码更新,我没有区分标记和点,你怎么样?标记是人们用来识别给定点的东西,不是? – jcolebrand
我区分这两个因为点属于矢量和标记不。我认为。从查看标记的api,可以找到可以解决我的问题的事件属性。 – Paul
啊,非常好,我明白你的意思了。另外,希望你现在可以解决它。 – jcolebrand