当我拖动我的功能并触摸其他功能openLayers时更改图标

时间:2014-07-11 09:11:09

标签: javascript json openlayers drag geojson

我需要你的帮助,我正在寻找可以让我在触摸其他功能时更改功能图标的技巧。     当我拖动我的功能geojson_etat3并且我放入mh_layer时我需要的是我想要geojson_etat3的图标变为./images/Etat3.png

=============================================== =========================

var geojson_etat3 = new OpenLayers.Layer.Vector("etat3", {
            styleMap: new OpenLayers.StyleMap({
                        "default": new OpenLayers.Style({
                        externalGraphic: './images/Etat3.png', 
                        graphicWidth: 21, 
                        graphicHeight: 25,
                        graphicYOffset: -24,
                        label : "${name}"
                        } ),

                        }),

                     // renderers: renderer,
                                          //'draggable': true,
            projection: epsg4326,
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.HTTP({
                url: "data/data_etat3.json",
                format: new OpenLayers.Format.GeoJSON()
                })

            });

这是我的第二个特色,将由geojson_etat3触及:

      var mh_layer = new OpenLayers.Layer.Vector("Equipe", {
                        styleMap: new OpenLayers.StyleMap({
                        "default": new OpenLayers.Style({
                            pointRadius: 5,
                            fillColor: "red",
                            strokeColor: "#0d4cd6",
                            strokeWidth: 1,
                            strokeOpacity: 0.8,
                            label:  "\n${name}"
                        } ),

                    }),

                         //renderers: renderer,
                        // 'draggable': true,
                        projection: epsg4326,
                        strategies: [new OpenLayers.Strategy.Fixed()],
                        protocol: new OpenLayers.Protocol.HTTP({
                            url: "data/data_ot.json",
                            format: new OpenLayers.Format.GeoJSON({
                                extractAttributes: true
                            })
                        })

                    });

我这样做但却徒劳无功:

controls = { 
   drag3 : new OpenLayers.Control.DragFeature(geojson_etat3,{ autoActivate: true, 
   overFeature: function(feature){ styleMap: new OpenLayers.StyleMap({ 
    "default":   new OpenLayers.Style({ externalGraphic: './images/Etat4.png' } ) }) } 

//onComplete: function() {alert('Are you sure this is the right postion?')} })
};

        for(var key in controls) {
                                map.addControl(controls[key]);
        }

提前谢谢。

0 个答案:

没有答案