2016-07-22 130 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

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