maps-api-for-javascript-examples
maps-api-for-javascript-examples copied to clipboard
H.ui.base.Button(); is not working ... it creates a div
trafficstars
I tried to insert specific controls in a here map.
H.ui.base.Button();is not working ... it creates a div- It is not possible to add attributes to
buttonsuch asaltortitlethru the api. - i tried to make addEventListener working but without success (may be my code is wrong).
var U_I = new H.ui.UI(map);
var container = new H.ui.Control();
container.addClass('here-ctrl here-ctrl-group');
var button = new H.ui.base.Element('button', 'here-ctrl-icon map_control');
container.addChild(button);
button.addEventListener('click', function() { alert(1); });
var button = new H.ui.base.Element('button', 'here-ctrl-icon map_center');
container.addChild(button);
button.addEventListener('click', function() { alert(2); });
container.setAlignment('top-right');
U_I.addControl('myControls', container );
U_I.addControl('ScaleBar', new H.ui.ScaleBar() );
the rendering is made by css

You didn't create a Button, you created a base/abstract H.ui.base.Element which you called button.
Try changing button to be a new H.ui.base.Button: https://developer.here.com/documentation/maps/3.1.18.1/api_reference/H.ui.base.Button.html