Air StageWebView Leaflet 地图图像在 android 上呈锯齿状

Air StageWebView Leaflet map images are jagged on android

我想使用 StageWebView class 将传单地图合并到 ios 和 android 空中移动应用程序中。 不幸的是,地图图像的质量参差不齐,很难辨认出街道名称。似乎有一些小的缩放正在进行。 出于测试目的,我在 http://leafletjs.com/examples/quick-start-example.html

使用了传单教程 mal

在 Android 浏览器 ( chrome ) 中查看时,图像看起来不错。 下面是一些简单的代码来说明问题:

package  {
import flash.display.MovieClip;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.media.StageWebView;    
import flash.geom.Rectangle;
import flash.desktop.NativeApplication;
import flash.utils.setTimeout;
public class Main extends MovieClip{

    private var _stageWebView:StageWebView 
    public function Main() 
    {

        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
        setTimeout( init,  100 );

    }
    private function init():void {
        _stageWebView = new StageWebView();
        _stageWebView.stage = this.stage;
        _stageWebView.viewPort = new Rectangle( 0, 0, stage.stageHeight, stage.stageWidth );
        _stageWebView.loadURL( "http://leafletjs.com/examples/quick-start-example.html" );
    }
}

}

有什么想法吗?是否与分辨率问题有关?

谢谢

如果您将其更改为使用 nativeMode new StageWebView(true) 它可以解决我的问题,但 mouse/touch 事件不起作用:/

您遇到的问题是渲染问题,您可以通过启用 hardware acceleration(强制 GPU 渲染)当然可以避免它。

Beginning in Android 3.0 (API level 11), the Android 2D rendering pipeline supports hardware acceleration, meaning that all drawing operations that are performed on a View's canvas use the GPU.

所以要强制GPU渲染,你可以:

1 - Enable hardware acceleration in your application's manifest file,您应该将应用程序元素的 android:hardwareAccelerated 属性设置为 true :

<android>
    <manifestAdditions> 
        <![CDATA[ 
            <manifest> 
                <application android:hardwareAccelerated="true"/> 
            </manifest> 
        ]]> 
    </manifestAdditions> 
</android>

这是完整清单文件的示例(我的测试浏览器-app.xml):

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<application xmlns="http://ns.adobe.com/air/application/19.0">
    <id>browser</id>
    <versionNumber>1.0.0</versionNumber>
    <versionLabel/>
    <filename>browser</filename>
    <description/>
    <name>browser</name>
    <copyright/>
    <initialWindow>
        <content>browser.swf</content>
        <systemChrome>standard</systemChrome>
        <transparent>false</transparent>
        <visible>true</visible>
        <fullScreen>false</fullScreen>
        <renderMode>auto</renderMode>
        <autoOrients>true</autoOrients>
    </initialWindow>
    <icon/>
    <customUpdateUI>false</customUpdateUI>
    <allowBrowserInvocation>false</allowBrowserInvocation>
    <android>
        <manifestAdditions>
        <![CDATA[
            <manifest>
                <uses-permission android:name="android.permission.INTERNET"/>
                <application android:hardwareAccelerated="true"/>
            </manifest>
        ]]>
        </manifestAdditions>
    </android>
</application>

然后您只需发布您的 AIR 应用程序,您将得到如下内容:

当我评论时你可以看到结果 <application android:hardwareAccelerated="true"/> :

2 - 您还可以从 Android 设备的开发人员选项中强制进行 GPU 渲染:

即使评论 <application android:hardwareAccelerated="true"/> 也可以获得相同的结果:

就这些!

希望能帮到你。