[OpenLayers-Users] onmouseover icon change

Neelima Emmani neelima.emmani at iictechnologies.com
Tue Apr 3 03:05:29 EDT 2012


Hi Andreas,

Thank you for the response.
Actually, i am able to set default and select style for my data.
So, by default it gives image-1 and on select it shows with image-2. But inbetween i want to specify another style on hover/mouseover. At this point i am stuck-up.

My code goes as follows--

//MARINA HARBOUR LAYER
    var mh_style_def = new OpenLayers.Style({'externalGraphic': "http://localhost/openlayers/img/mh.png",
                                      'graphicHeight': 25,
                                      'graphicWidth': 21,
                                      'graphicXOffset': -10.5,
                                      'graphicYOffset': -12.5
                });
  var mh_style_sel = new OpenLayers.Style({'externalGraphic': "http://localhost/openlayers/img/mh_sel.png",
                                      'graphicHeight': 25,
                                      'graphicWidth': 21,
                                      'graphicXOffset': -10.5,
                                      'graphicYOffset': -12.5
                });
var mh_style_tmp = new OpenLayers.Style({'externalGraphic': "http://localhost/openlayers/img/mh_tmp.png",
                                      'graphicHeight': 25,
                                      'graphicWidth': 21,
                                      'graphicXOffset': -10.5,
                                      'graphicYOffset': -12.5
           });

    var mh_styleMap = new OpenLayers.StyleMap({'default':mh_style_def, 'temporary': mh_style_tmp, 'select': mh_style_sel});

   var mhlayer = new OpenLayers.Layer.Vector("mh", {styleMap: mh_styleMap,
                                                        strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
                                                        protocol: mh_protocol
                                                });

    map.addLayer(mhlayer);


//Hover Control
    hovercontrol = new OpenLayers.Control.GetFeature({
                   protocol: mh_protocol,
                   box: true,
                   hover: true,
                   multipleKey: "shiftKey",
                   toggleKey: "ctrlKey"
              });
    hovercontrol.events.register("hoverfeature", this, function(e) {
                here i want to add a code to specify the new style .And i am not able to
            });

When i say "hover:true" does the openlayers take temporary option in style map or do i need to register event?

With Regards,
Neelima Emmani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120403/4f32cc5f/attachment.html


More information about the Users mailing list