maps-api-for-javascript-examples icon indicating copy to clipboard operation
maps-api-for-javascript-examples copied to clipboard

H.ui.base.Button(); is not working ... it creates a div

Open mailpress opened this issue 6 years ago • 1 comments
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 button such as alt or title thru 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

8cwmj

mailpress avatar Feb 16 '19 08:02 mailpress

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

endafarrell avatar Sep 04 '20 12:09 endafarrell