// Preparation for the custom control:
var anchor_element = document.createElement('a');
anchor_element.href = '#custom_href';
anchor_element.className = 'custom_anchor';
var this_ = this;
var handleCustomControl = function (e) {
myControl.customFunction(e);
};
anchor_element.addEventListener('click', handleCustomControl, false);
anchor_element.addEventListener('touchstart', handleCustomControl, false);
var custom_element = document.createElement('div');
custom_element.className = 'myCustomControl ol-unselectable';
custom_element.appendChild(anchor_element);
myControl = new ol.control.Control({
className: 'myControl',
element: custom_element,
target: document.getElementById("myCustomControl")
});
CSS-rule (to be able to click on the hyperlink):
.custom_anchor:before {
content:"Cycle";
}
I gave it a quick try and can use a custom Control:
http://jsfiddle.net/expedio/onn6g33c/
Probably it's a better choice to set up a control like this if it's getting a bit more complex:
http://jsfiddle.net/expedio/j4duqc9s/