Disable default popup on Azure Maps SimpleDataLayer

Hannes Dendoncker 0 Reputation points
2024-06-13T13:51:18.1033333+00:00

Hello,

I'm trying to open an external link from a SimpleDataLayer popup. Therefore I need to edit the 'sandbox' property from the popup Iframe, and set it to 'allow-popups allow-popups-to-escape-sandbox'. Below is what I found in the SimpleDataLayer docs.

"This simple data layer uses the popup template class to display KML balloons or feature properties as a table. By default, all content rendered in the popup will be sandboxed inside of an iframe as a security feature. However, there are limitations:

  • All scripts, forms, pointer lock and top navigation functionality is disabled. Links are allowed to open up in a new tab when clicked.
  • Older browsers that don't support the srcdoc parameter on iframes will be limited to rendering a small amount of content.

If you trust the data being loaded into the popups and potentially want these scripts loaded into popups be able to access your application, you can disable this by setting the popup templates sandboxContent option to false."

Unfortunately, it only explains it is possible to set this option, but never explains how. So, I tried making my own popup, where I can set the sandbox property to whatever I want. I linked the popup to the SimpleDataLayer, but now, there's two popups. I would like to disable the original popup that came with the SimpleDataLayer.

In the Azure Maps SimpleDataLayer docs I read the following:

"In addition to styling features, the SimpleDataLayer provides a built-in popup feature with a popup template. The popup displays when a feature is clicked. The default popup feature can be disabled, if desired."

Once again, it says it is possible, but does not explain how. I looked everywhere in the SimpleDataLayer options and properties, but could not find anything. I also looked for an onClick event in map.events that could explain how it's opening the popup, but there's none to be found.

In the end, all I want is to be able to open external links from a popup form a SimpleDataLayer, if I'm doing this the wrong way, overcomplicating it, please tell me how to do it the right way.

Thanks in advance.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
634 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. rbrundritt 16,236 Reputation points Microsoft Employee
    2024-06-13T14:44:55.8+00:00

    The SimpleDataLayer options allow you to set a popupTemplate. You can set this option either when creating the layer or later you set the options. For example:

    layer = new atlas.layer.SimpleDataLayer(datasource, {
    	popupTemplate: {
    		sandboxContent: false
    	}
    });
    

    or set it later:

    layer.setOptions({
    	popupTemplate: {
    		sandboxContent: false
    	}
    });
    

    Setting options for any layer, and most other things in the SDK use the same flow where you can set the options when creating and instance of the class, and the class usually has setOptions and getOptions functions.

    0 comments No comments