1
var vectormap = new OpenLayers.Layer.Vector('Overlay',
    {
        styleMap: new OpenLayers.StyleMap(
        {
            "default": new OpenLayers.Style({
                           externalGraphic: 'girl.png',
                           graphicWidth: 50,
                           graphicHeight: 50,
                           graphicYOffset: -24,
                           title: 'marker'}),
            "select": new OpenLayers.Style({
                           externalGraphic: 'boy.png',
                           graphicWidth: 16,
                           graphicHeight: 26,
                           graphicYOffset: -24,
                           title: 'marker_select'})
        })
    });
featurearray = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(113.950,33.019));
vectormap.addFeatures([ featurearray ]); 

This is my vector layer, but a bit wrong, my png image title attribute can not be displayed when the mouse to move up, I checked the official website the "OSM with Marker and Popup.html" code, exactly the same, you know why.

1

It looks like you are using canvas but title option does not supported by the canvas renderer. Try to configure you vector layer following way:

var vectormap = new OpenLayers.Layer.Vector('Overlay',
{
    styleMap: new OpenLayers.StyleMap(
    {
        "default": new OpenLayers.Style({
                       externalGraphic: 'girl.png',
                       graphicWidth: 50,
                       graphicHeight: 50,
                       graphicYOffset: -24,
                       title: 'marker'}),
        "select": new OpenLayers.Style({
                       externalGraphic: 'boy.png',
                       graphicWidth: 16,
                       graphicHeight: 26,
                       graphicYOffset: -24,
                       title: 'marker_select'})
    })
    renderers: ["SVG", "VML", "Canvas"]
});
  • Oh,my god, my openlayers version is wrong. . .sorry! – harryfly Jan 29 '13 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.