2016-07-22 98 views
1

我正在使用MapContainer(cn1lib)。所以在Android设备低relsolution缩放工作正常。但在Android设备高分辨率的变焦不能正常工作。放大距离远。我附上一个屏幕,以最大放大,这是一个错误,或者我错了?CodenameOne MapContainer缩放级别

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. 
} 

}

+0

请张贴一些代码,以便我们可以帮助您更好。 – Bek

+0

我已更新帖子,谢谢 –

回答

0

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

这会将实际的本地GUI嵌入到在设备上看起来和感觉都更好的位置,尽管它在模拟器上看起来相同。

+0

谢谢,完美的作品,你救了我 –