CodenameOne MapContainer缩放级别

时间:2016-07-22 17:13:03

标签: codenameone

我正在使用MapContainer(cn1lib)。所以在Android设备低relsolution缩放工作正常。但在Android设备高分辨率下缩放不能正常工作。放大远。我附加了一个带有最大放大的屏幕,这是一个错误或者我错了吗?

SCREENSHOT

GUI-DESIGN

公共类StateMachine扩展了StateMachineBase {

MapContainer mapContainer;

public StateMachine(String resFile) {
    super(resFile);
    // do not modify, write code in initVars and initialize class members there,
    // the constructor might be invoked too late due to race conditions that might occur
}

/**
 * this method should be used to initialize variables instead of the
 * constructor/class scope to avoid race conditions
 */
protected void initVars(Resources res) {
}

@Override
protected void beforeShow(Form f) {
    try {

        this.mapContainer.setShowMyLocation(true);
        this.mapContainer.zoom(new Coord(20.640086, -103.432207), 17);
        this.mapContainer.setCameraPosition(new Coord(20.640086, -103.432207));
        this.mapContainer.addMarker(
                EncodedImage.createFromImage(fetchResourceFile().getImage("pin.png"), false),
                new Coord(20.640086, -103.432207),
                "Hi marker", "Optional long description",
                new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        Dialog.show("Marker Clicked!", "You clicked the marker", "OK", null);
                    }
                }
        );


        this.mapContainer.addPointerDraggedListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                mapContainer.clearMapLayers();
                mapContainer.addMarker(EncodedImage.createFromImage(fetchResourceFile().getImage("pin.png"), false), mapContainer.getCameraPosition(), "Hi marker", "Optional long description", new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        Dialog.show("Marker Clicked!", "You clicked the marker", "OK", null);
                    }
                });

            }
        });

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    super.beforeShow(f); //To change body of generated methods, choose Tools | Templates.
}

@Override
protected Component createComponentInstance(String componentType, Class cls) {
    if (cls == MapComponent.class) {    
        this.mapContainer = new MapContainer();
        return this.mapContainer;
    }
    return super.createComponentInstance(componentType, cls); //To change body of generated methods, choose Tools | Templates.
}

}

1 个答案:

答案 0 :(得分:0)

这是MapComponent而不是原生地图,所以它使用旧的开放街道地图支持和相对简单的地图渲染甚至在设备上。我们支持native google maps,但未在GUI构建器中公开,但您可以通过代码添加它。

这会将实际的原生GUI嵌入到位,虽然在模拟器上看起来会一样,但设备上的外观和感觉都会更好。