CodenameOne MapContainer缩放级别
我正在使用MapContainer(cn1lib)。因此,在android设备中,缩放效果很好。但在安卓设备中,高分辨率的变焦效果不佳。放大后的图像会保持较远的距离。我附加了一个最大放大的屏幕,这是一个错误还是我错了 公共类StateMachine扩展了StateMachineBase{CodenameOne MapContainer缩放级别,codenameone,Codenameone,我正在使用MapContainer(cn1lib)。因此,在android设备中,缩放效果很好。但在安卓设备中,高分辨率的变焦效果不佳。放大后的图像会保持较远的距离。我附加了一个最大放大的屏幕,这是一个错误还是我错了 公共类StateMachine扩展了StateMachineBase{ MapContainer mapContainer; public StateMachine(String resFile) { super(resFile); // do not mod
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.
}
}这是一个
MapComponent
而不是本地地图,因此它使用旧的开放式街道地图支持和相对简单的地图渲染,即使在设备上也是如此。我们有GUI构建器中未公开的支持,但您可以通过代码添加它
这将嵌入实际的本机GUI,在设备上看起来和感觉都会更好,尽管在模拟器上看起来是一样的。请发布一些代码,以便我们能更好地帮助您。我已经更新了帖子,谢谢