Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with BodyOnLoad

Hello at all,

i want to make this in my QlikView Extension:

<script type="text/javascript">

    var ge;

    google.load("earth", "1");

    google.load("maps", "2");

    function init() {

      google.earth.createInstance('map3d', initCallback, failureCallback);

      addSampleUIHtml(

        '<input id="location" type="text" value="Hermannstr.106-107,12051 Berlin"/>'

      );

      addSampleButton('Fly Here!', buttonClick)

    }

    function initCallback(instance) {

      ge = instance;

      ge.getWindow().setVisibility(true);

      // add a navigation control

      ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);

      // add some layers

      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);

      ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);

      document.getElementById('installed-plugin-version').innerHTML =

        ge.getPluginVersion().toString();

    var link = ge.createLink('');

    var href = 'http://www.rsp-gmbh.de/uploads/berlin2.kmz';

    link.setHref(href);

    var networkLink = ge.createNetworkLink('');

   networkLink.set(link, true, true); // Sets the link, refreshVisibility, and flyToView

    ge.getFeatures().appendChild(networkLink);

    }

    function failureCallback(errorCode) {

    }

<body onload="init()" style="font-family: arial, sans-serif; font-size: 13px; border: 0;">

<script type="text/javascript">

    var ge;

    google.load("earth", "1");

    google.load("maps", "2");

    function init() {

      google.earth.createInstance('map3d', initCallback, failureCallback);

      addSampleUIHtml(

        '<input id="location" type="text" value="Hermannstr.106-107,12051 Berlin"/>'

      );

      addSampleButton('Fly Here!', buttonClick)

    }

    function initCallback(instance) {

      ge = instance;

      ge.getWindow().setVisibility(true);

      // add a navigation control

      ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);

      // add some layers

      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);

      ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);

      document.getElementById('installed-plugin-version').innerHTML =

        ge.getPluginVersion().toString();

    var link = ge.createLink('');

    var href = 'http://www.rsp-gmbh.de/uploads/berlin2.kmz';

    link.setHref(href);

    var networkLink = ge.createNetworkLink('');

   networkLink.set(link, true, true); // Sets the link, refreshVisibility, and flyToView

    ge.getFeatures().appendChild(networkLink);

    }

    function failureCallback(errorCode) {

    }

<body onload="init()" style="font-family: arial, sans-serif; font-size: 13px; border: 0;">

How does it work under QlikView with the Body on Load?

Thx

13 Replies
Not applicable
Author

When i put it back, i have the same error: google is not defined.

function init()

{

  google.earth.createInstance('map3d', initCallback, failureCallback);

}

function initCallback(instance) {

      ge = instance;

      ge.getWindow().setVisibility(true);

   

      // add a navigation control

      ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);

   

      // add some layers

      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);

      ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);

   

      document.getElementById('installed-plugin-version').innerHTML =

      ge.getPluginVersion().toString();

    }

   

function failureCallback(errorCode) {

    }

Qva.LoadScript ("http://www.google.com/jsapi?key=ABQIAAAAjb153tfjyia9Ika9RRA5XRQvj1FOGbPa-QZOl8b2Ik1zUoqqmRQ6gKby6E2c...");   

var QVGlobal;

                    var ge;

                    google.load("earth", "1");

                    google.load("maps", "2");

           

                    document.onload = init();

          Qva.AddExtension('GoogleEarth', function() {

          //Write HTML-Page

            var html="";

            html+="<div id='map3d' style='width: 600px; height: 400px;'></div>"; 

        this.Element.innerHTML = html;

          },true);

Brian_Munz
Employee
Employee

You still need to wrap everything in that LoadScript like I did above. Otherwise, you're calling the google functions before the script is loaded. If you do it like above, the script waits until the google js is loaded before continuing.

Not applicable
Author

Thx for the answer,but i´m not sure how i can make this?

There was the problem das the second parameter is the callback function.Therefore it doesn´t work.

Qva.LoadScript("http://www.google.com/jsapi?key=ABQIAAAAjb153tfjyia9Ika9RRA5XRQvj1FOGbPa-QZOl8b2Ik1zUoqqmRQ6gKby6E2c...", function() {

          Qva.AddExtension('GoogleEarth', function() {

                    var ge;

                    google.load("earth", "1");

                    google.load("maps", "2");

                    document.onload = init(this.Element);

          },true);

});

Is there another way how i can realize it?

Brian_Munz
Employee
Employee

BTW, to answer your initial question, the problem with the first bit of code you posted was the single quotes.

Try something like this:

Qva.BodyOnLoadFunctionNames.push(init());