Codenameone本机地图离线? [英] Codenameone native maps offline?
问题描述
引起我注意的是,当我在codenameone中使用本机地图并尝试更改相机位置时,地图变为空白,无论如何,我是否可以在没有互联网连接的情况下使用本机地图功能
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 :
使用脱机方法时在IOS上遇到的异常:
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
问候,
推荐答案
据我所知,Google Native Maps不支持离线功能,尽管他们的应用程序对此具有某些支持。您可以使用它不提供与本机地图相同级别的UX,但可以离线使用: https:// github.com/shannah/CN1OfflineMaps
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
这篇关于Codenameone本机地图离线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!