Customization of navigation menu button

does anyone know if there is a way to make a navigation menu button a trigger for a URL

Adding a button to the view list might be tricky. Would a button in the bottom right corner work for you? If so, copy the button icon to extra-assets subdirectory of the scene directory (in Documents\Shapespark) add the following body-end.html file in the scene directory:

<script>
  var viewer = WALK.getViewer();
  var button = viewer.addMenuButton('$EXTRA_ASSETS/name-of-the-icon-file');
  button.addEventListener('click', function() { viewer.openUrl('https://url-to-open'); });
</script>

replacing name-of-the-icon-file and url-to-open with appropriate values.

How should I set icon file pixel ratio?

@inno_viz, I am sorry, but I don’t understand the question. Could you write in more detail what you’d like to achieve?

The trigger icon for a URL is so small. How can I make it bigger?
I also want clicking the trigger icon for a URL to a new tab.

If your icon image has some margin you can remove the margin so that the icon covers the whole image area.

Use: viewer.openUrl('https://url-to-open', true) to open the URL in a new tab.

1 Like

Thank you. It works.

hello.
Is there a way to remove it in reverse?

I am sorry, but I don’t understand this question. Could you write in more detail what you’d like to achieve?

I want to know how to remove “url” and “Popup”.

ex) viewer.removeUrl()??

Do you mean closing the browser tab/window opened with viewer.openUrl. I am afraid it’s not possible, only the user can close it.

ex)
viewer.openUrl(“Customization of navigation menu button - #9 by wojtek”, true); <—remove

I want to know the code of the script to be remove.

This is not possible currently, but we’ll update our viewer API next week to allow for closing the browser window/tab opened with viewer.openUrl.

1 Like

We’ve rolled out the API update. If you open a new browser window/tab with with:

const win = viewer.openUrl('https://url-to-open', true);

you can close the window later on with:

win.close();