简体   繁体   中英

Change cursor style to pointer for clickable markers

I have created a map with a couple of markers on it using the v3 here maps javascript api.
When clicking on the markers an infobubble for the clicked marker show up.

By default the cursor style stays the same when hovering over the marker. Giving the impression to the user that the marker is not clickeable.

Is there a way to make to change the cursor style to a pointer ( http://www.javascripter.net/faq/stylesc.htm )?
That way a user will notice that the marker is clickeable.

If you are using this example then you can see group is a DOM element. Therefore, we can apply a simple javascript code:

group.style.cursor = "pointer"

Your function will look something like this:

function addInfoBubble() {
  var group = new H.map.Group();

  map.addObject(group);
  group.style.cursor = "pointer";
  // add 'tap' event listener, that opens info bubble, to the group
  group.addEventListener('tap', function (evt) {
    // event target is the marker itself, group is a parent event target
    // for all objects that it contains
    var bubble =  new H.ui.InfoBubble(evt.target.getPosition(), {
      // read custom data
      content: evt.target.getData()
    });
    // show info bubble
    ui.addBubble(bubble);
  }, false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM