dimanche 28 juin 2015

Air WebView HTML/Javascript-Page does not show in iOS if it is generated at runtime

i am trying do display a small map in a crossplatform mobile application developed in Air. Since there is no native Map-API I decided to just use a simple Leaflet map and display it in a StagWebView. It works perfectly, when I load the HTML from a server, but does not show in the iOS Simulator or on a device if i pass the HTML as a String.

Is this maybe some security restriction because of the Javascript?

this is the html code:

<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="http://ift.tt/1TWUABO" />
    <title>Hello Map</title>
</head>
<body>
    <h1>Hello Map</h1>
    <div id="map" style="width: 200px; height: 200px"></div>
    <script src="http://ift.tt/1oZnLGo"></script>
    <script>
        var def_lat=42;
        var def_lng=13;
        var def_zoom_lvl=15;
        var def_position=[def_lat, def_lng];
        var mymap = L.map("map",{attributionControl: true}).setView(def_position, def_zoom_lvl);
        var openstreet= L.tileLayer('http://ift.tt/UdqNor', {
            maxZoom: 18,
            attribution: 'Map data &copy; <a href="http://ift.tt/ItuEqj">OpenStreetMap</a>',
        });
        openstreet.addTo(mymap);
    </script>
</body>

and this is the simple AS code:

public static var XML_DATA:XML=<html lang="en">
        <head>
            <meta charset="utf-8">
        .....
        like above in html code

and then:

_map = new WebView();
_map.loadString(XML_DATA.valueOf().toString());
addChild(_map);

thanks for help.

Aucun commentaire:

Enregistrer un commentaire