当鼠标滑过,点击地图时,高亮显示,触发事件

回调函数
    var wfs = new OpenLayers.Layer.Vector("WFS", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        projection: new OpenLayers.Projection("EPSG:4326"),
        styleMap: myStyles,
        displayInLayerSwitcher: true,
        //styleMap: new OpenLayers.StyleMap({ externalGraphic: "../images/pic_left.png", graphicOpacity: 0.3, graphicWidth: 10, graphicHeight: 10 }), 
        protocol: new OpenLayers.Protocol.WFS({
            version: "1.0.0",
            url: "http://" + WMS_ipAdress + "/geoserver/TJDG/wfs",
            featureType: "xqpostgis5326",
            featurePrefix: "TJDG",
            featureNS: "http://www.tjdg.com",
            srsName: "EPSG:4326",
            geometryName: "the_geom"
        })
    });
   
    map.addLayers([wfs]);

/*    var select =  new OpenLayers.Control.SelectFeature(
                    wfs,
                    {
                        clickout: true,
                        toggle: false,
                        multiple: false,
                        hover: false,
                        toggleKey: "ctrlKey", // ctrl key removes from selection
                        multipleKey: "shiftKey", // shift key adds to selection
                        box: true
                    }
            );
    map.addControl(select);
    select.activate();
*/

    var selecthover = new OpenLayers.Control.SelectFeature(
                    wfs,
                    {
                        toggle: true,
                        highlightOnly:true
                    }
            );
     map.addControl(selecthover);
     selecthover.activate();
     selecthover.events.on({
        'featurehighlighted': function(feature) {
             var sFch = feature.feature;
             var pt = sFch.geometry.getBounds().getCenterLonLat();
             alert(pt.lon);
             
        },
        'featureunhighlighted': function(feature) {
            //alert(1);
        }
    });

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值