Angular Leaflet in Cordova wrapper doesn't load tiles due to protocol mismatch
我刚刚开始使用Angular Leaflet指令(http://tombatossals.github.io/angular-leaflet-directive/#!/),并且正在尝试将其集成到Ionic项目中。铅>
在浏览器上,一切正常:加载了地图切片。当我使用XCode编译应用程序并在iOS模拟器中运行时,切片未按预期加载。
使用检查器时,我注意到加载的图块的html格式如下:
请注意,缺少带有src属性的协议。在Cordovapackage器中,该应用程序假定该文件应为file://,并且自然无法加载到图块中。
有什么办法可以实现:
GitHub问题:https://github.com/tombatossals/angular-leaflet-directive/issues/460
我不知道问题的确切原因,但这似乎与最新版的Leaflet指令有关。
作为解决此问题之前的最新解决方法,请使用angular-leaflet v0.7.7而不是最新版本。
如果使用Bower,请将bower.json行更改为
1 | "angular-leaflet":"0.7.7" |
确保它不是\\'?0.7.7 \\'
希望这会有所帮助!
此问题似乎已在当前版本的Angular Leaflet Directive中解决。
我当前在控制器中使用此代码,并且可以在浏览器以及设备上使用:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | angular.extend($scope, { center: { lat: 52.367215, lng: 4.893036, zoom: 1 }, maxbounds: {}, defaults: { maxZoom: 16, minZoom: 12, tileLayer:"http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png", tileLayerOptions: { opacity: 0.9, detectRetina: true, reuseTiles: true, }, scrollWheelZoom: true } }) |