KOch
KOch

Reputation: 1

DJ Native Web browser not opening GoogleMap html with js while Chrome does

I'm making an app with GoogleMap inside DJ Native webBrowser component. I load page as a string using webBrowser.setHTMLContent(String). HTML file contains JavaScript which add markers to map.

I made simple html file with google-maps-api functions. It works perfect on Chrome as well as Firefox. But not in webBrowser (djnative).

I discovered that script without new marker statement(google.maps.Marker) works OK.

Have anyone got any idea what's wrong? Is there any way to show console log from webBrowser (like ctrl+shift+J in Chrome)

This is script code:

<script type="text/javascript" src=https://maps.googleapis.com/maps/api/js?key=[MY_KEY]&sensor=false">
    </script>
    <script type="text/javascript">
      var map;
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(52.236302, 21.007636),
          zoom: 10
        };
        map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);

        var t = [];
        var x = [];
        var y = [];
        var h = [];

        t.push('Location Name 1'); 
        x.push(52.232097);
        y.push(20.927985);
        h.push('<p><strong>Location Name 1</strong><br/>Address 1</p>');

        t.push('Location Name 2'); 
        x.push(52.245097);
        y.push(20.945985);
        h.push('<p><strong>Location Name 2</strong><br/>Address 2</p>');

        /*this is error making code*/
        var i = 0;
        for ( item in t ) {
              var marker = new google.maps.Marker({
              position: new google.maps.LatLng(x[i], y[i]),
              map: map,
              title: t[i],
          });
            i++; 
        }   /*this is end of error making code*/


    }
      google.maps.event.addDomListener(window, 'load', initialize);

    </script>

Upvotes: 0

Views: 175

Answers (1)

benchpresser
benchpresser

Reputation: 2188

1.Dj is using ie as default. did you try opening the html with ie?

2.In dj, you can not always setting the content and expect it run. for example, the tinymce editor, does not run if you set the editor.html (html containint tinymce) directly. That is why the author of dj made internal webserver for editors. You have to call it through an address (for editor ck and tinymce, dj calls localhost, http://127.0.0.1/tinymce/.. but the structure is too complex to be detailed here. you may try for testing purpose, putting your html to a simple web page (tomcat) and call it through loadURL (instead of setContent)

Upvotes: 0

Related Questions