Access to map object and function in web map application

05-24-2020 01:10 AM
New Contributor II


I have an iframe with a downloaded web map application. How can I access to map object and map functions from another iframe?
And if I need to add some custom functions, where is the best place to write them?

Thanks Martina 

0 Kudos
4 Replies
MVP Esteemed Contributor



  Normally you have a global var that references the opener. Something like this:

document.winobj ="someurl", "_blank", features);

Then that html file has public functions or methods that you call using document.winobj


Then in the html file I opened, it can get access back to the widget using something like this:

window.opener.document.myWidget.setLatLonHandler(, pt.lng());

The document.myWidget was set inside the widgets postCreate method:

document.myWidget = this;
New Contributor II

Hi Robert

thanks for your answer!

I’m new in WAB developing and there are some not clear questions.

Do you mean that I have to write my custom function in a Widget?

For example, if I want call a function like “ZoomToPoint” (see below) from a button inside IframeA, which makes a map zoom in the webapplication in IframeB, have I necessarily to create a widget in the web app with public ZoomToPoint function? Is it not possible to write this function in a custom js file which accesses the map?






], function(





) {


 function zoomToPoint(pttesto){;

  var sms = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE,6new SimpleLine Symbol(SimpleLineSymbol.STYLE_SOLIDnew Color([255,0,0]), 1), new Color([255,0,0,0.25]));  



  var graphic = new esri.Graphic(ptsms);;

  //addLabel(pt, testo,0,5)




Thanks for your help

I appreciate very much


0 Kudos
MVP Esteemed Contributor


   No you may not need a custom widget. I was providing a method that I personally use as an example for you to understand and adjust to your workflow and use case. The big thing to takeaway is the use of global vars and functions.

0 Kudos
New Contributor II

Thank you

You are very kind

0 Kudos