2017-06-13 65 views
1

我在我的項目中集成了原生地圖庫。地圖在模擬器中使用javascript鍵作爲MapContainer中的參數快速加載。但在Android設備中,我必須刪除參數才能使其工作。 Ps:所有必需的API都保存在構建提示中。但它在android設備中加載非常緩慢。我必須等待幾分鐘才能加載地圖。如果我放大,地圖消失,並看到白色屏幕。如果我縮小,則會出現地圖。cn1中的本地地圖

您可以在縮放問題here上看到視頻。

我的代碼:

Form hi = new Form("Native Maps Test"); 
    hi.setLayout(new BorderLayout()); 
    final MapContainer cnt = new MapContainer(); 

    Style s = new Style(); 
    s.setFgColor(0xff0000); 
    s.setBgTransparency(0); 
    FontImage markerImg = FontImage.createMaterial(FontImage.MATERIAL_PLACE, s, 4); 

    cnt.setCameraPosition(new Coord(27.6738908, 85.3181375)); 
    cnt.addMarker(
      EncodedImage.createFromImage(markerImg, false), 
      new Coord(27.6738908, 85.3181375), 
      "Hi marker", 
      "Optional long description", 
      evt -> { 
       ToastBar.showMessage("You clicked the marker", FontImage.MATERIAL_PLACE); 
      } 
    ); 
    hi.add(BorderLayout.CENTER, cnt); 
    hi.show(); 
    hi.revalidate(); 

回答

0

這不是一個原生地圖。這是後備地圖組件。您需要驗證是否啓用了Android本地地圖。我建議用電纜連接設備並查看Google在控制檯中輸入的錯誤。

+0

我很困惑。如果出現任何問題,它仍然會顯示地圖?你能再清一點嗎? – beck

+1

實際上它有點壞,它應該顯示JavaScript地圖,但它顯示的是'MapComponent'後備。如果出現故障,我們仍然嘗試顯示地圖回退,因爲這是大多數開發人員想要的。例如。假設我在沒有Google Play服務的Kindle ASOP設備上運行,您仍然希望地圖「正常工作」正確嗎? –