Codenameone native maps offline?

2019-06-01 11:40发布

it was brought to my attention that when I use the native maps in codenameone , and try to change the camera position the maps get blank , is there anyway that I could use the native maps functionality with no internet connection

final String HTML_API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
 final MapContainer cnt = new MapContainer(HTML_API_KEY);
cnt.addMarker(EncodedImage.createFromImage(MarkerImg, false), new Coord(latitude, langitude), "", "", e3->{
});
Container root = LayeredLayout.encloseIn(
BorderLayout.center(cnt)
);
mapForm.add(BorderLayout.CENTER, root);
mapForm.revalidate();

Update :

The exception that I face on IOS when using the offline method :

MBTilesProvider provider = null;
        try{
            if ( MBTilesProvider.isLoaded("xxxxx.cn1tiles") ){
                provider = new MBTilesProvider("xxxxx.cn1tiles");
            } else {
                provider = MBTilesProvider.create("xxxxx.cn1tiles",fetchResourceFile().getData("xxxxx.cn1tiles"));
            }
        }catch(Exception e){
            e.printStackTrace();
            new GlobalOperations().ShowDialog(null, "OffLine Map", "there was a problem with loading the map file "+e.getMessage());
            return;
        }

java.lang.NullPointerException
    at ca_weblite_codename1_mapbox_MBTilesProvider.create:221
    at userclasses_StateMachine.beforeMap:5850
    at generated_StateMachineBase.beforeShow:5850
    at com_codename1_ui_util_UIBuilder.showForm:2518
    at com_codename1_ui_util_UIBuilder.showForm:2565

appreciate the help to make the map work with no internet connection

Regards,

1条回答
贪生不怕死
2楼-- · 2019-06-01 12:39

The Google Native Maps don't support offline functionality as far as I know although their app has some support for that. You can use this which doesn't offer the same level of UX as the native maps but works offline: https://github.com/shannah/CN1OfflineMaps

查看更多
登录 后发表回答