Support marker labels in OpenLayers #136

cyberhobo opened this Issue May 1, 2012 · 13 comments


None yet

6 participants


Ideas from a mailing list thread favor a static text label next to the marker, similar to Yahoo maps marker labels.


The OpenLayers demos show this capability, apparently through the use of "symbolizers".

Abstracting it to a "label" seems to fit into Mapstraction's goal.

The sandbox demos also appear to demonstrate this feature using OL, but they fail to materialize.

Perhaps this used to work at one time, and was broken in some past version.


Hi techiejohn, could you provide a link to the demo that you are talking about ? Maybe we could implemet marker's labels after that.


Ok, that's what i've already found by my side :)

These examples are not the same thing that we call "labels" in Mapstraction. By label, mapstraction means a classic tooltip as rendered with title on img tags for example (have a look at a demo with google api and setlabel).

Moreover, these examples use vector feature and not classic markers as we do by default in mapstraction.



The Yahoo provider then does not handle setLabel correctly, since it actually does what "labeling" should do in OL.

I know Mapstraction is trying to find the LCD between all the APIs, but then labeling either doesn't fit into that, or I think it should be called Popups or some other more descriptive concept (since there's no description in the documentation for what it does), or perhaps it can be added. I haven't looked at all the providers so I don't know how many of them would have some mechanism to provide this capability.


The odd thing about the choice that Labels are "title" tooltips, is that the sandbox OL example includes HTML tags. This was the reason (given lack of other documentation) I made the assumption that labels are what labels mean in the context of a map (e.g. a piece of text that appears on the map surface to describe a feature).

Did this ever work as a true label? I wonder why the choice was made in the sandbox demo to include HTML tags if this was simply supposed to have been a "title" attribute somewhere.


Has Dylan told you on the mailing list "The sandbox is kind of broken too". You're welcome if you want to help us to update this ;)


Yes, I got that. But it must have not been broken at some point, or that was just coded in the blind.

I'm just wondering if there's some older version of Mapstraction that had this working as the demo assumes, in which case I would go back and try to hack it back into the current release.


My best guess is that it was never implemented for OpenLayers - I've never seen a working example or any leftover code. I think the sandbox examples were intended to show behaviors of other providers.

The Yahoo vs. Google style is evident with the current code in tests/index.html. I like the Yahoo style for device friendliness, but you can see that it presents styling challenges. If we implemented the Yahoo style, existing OpenLayers users would probably unexpectedly find text all over their maps with the next release, having assumed the more common Google style.


I agree. I'd like the true labeling abstracted, but renaming your current "setLabel" to "setPopover" or "setPopup" and redefining "setLabel" will break people's stuff (although that's what release notes are for).

Perhaps this abstraction can be added in some future release and be called something else, like "addText" with an anchor such as N/S/E/W.


If use of OpenLayers Vector ( request #222 ) rather than OpenLayersMarker, it can be done with :
var markerStyle = OpenLayers.Util.extend({},['default']);
markerStyle.label = MY_LABEL;

Others options : markerStyle.labelAlign, markerStyle.labelYOffset, markerStyle.fontFamily, markerStyle.fontSize, etc...

Mapstraction member

Take a look at the release-2.1 branch; there's been a lot of rework to migrate OpenLayers support from OpenLayers.Marker to OpenLayers.Feature.Vector. Marker labels are also supported via mxn.Marker.setLabel(). Hopefully this meets your needs and I can close this issue down.

Mapstraction member

Please checkout the new release-3 branch which has the fixed Vector implementation however we aren't going to be addign the feature from here: as it would also need to be implemented on the other providers too, so I am closing this issue and have created a new feature request #276 for it instead.

@gilesc50 gilesc50 closed this Aug 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment