Ionic 4 Leaflet Map不适用于部署,但适用于离子服务--devapp

知识养成了思想,思想同时又在融化知识。这篇文章主要讲述Ionic 4 Leaflet Map不适用于部署,但适用于离子服务--devapp相关的知识,希望能为你提供帮助。
【Ionic 4 Leaflet Map不适用于部署,但适用于离子服务--devapp】我有一个带有传单/ openstreetmap的应用程序,它可以正常工作。在浏览器,android和ios设备上运行ionic serve --devapp时,地图可以完美运行。我已经通过使用电容器的android studio通过android studio达到了在android设备上进行部署测试的阶段,并且传单图块没有显示,没有错误可以找到,我确定它必须在某个地方。尽管传单/ openstreetmap磁贴不起作用,但标记和多边形以及我所有应用程序的功能均正常工作,只是没有磁贴。
我真的不知道问题是什么,如果对我的依赖项或插件的设置有任何建议,或者在config.xml或index.html中缺少建议,将不胜感激!
index.html

< !DOCTYPE html> < html lang="en"> < head> < meta charset="utf-8" /> < title> Ionic App< /title> < base href="https://www.songbingjia.com/" /> < meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> < meta name="format-detection" content="telephone=no" /> < meta name="msapplication-tap-highlight" content="no" /> < link rel="icon" type="image/png" href="https://www.songbingjia.com/android/assets/icon/favicon.png" /> < !--leaflet.js--> < script src="https://www.songbingjia.com/android/lib/leaflet/leaflet.js"> < /script> < script src="https://www.songbingjia.com/android/lib/leaflet/angular-leaflet-directive.min.js"> < /script> < script src="http://img.readke.com/220519/13562H421-2.jpg"> < /script> < !-- add to homescreen for ios --> < meta name="apple-mobile-web-app-capable" content="yes" /> < meta name="apple-mobile-web-app-status-bar-style" content="black" /> < /head> < body> < app-root> < /app-root> < /body> < /html>

config.json
< ?xml version='1.0' encoding='utf-8'?> < widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> < name> MyApp< /name> < description> An awesome Ionic/Cordova app.< /description> < author email="hi@ionicframework.com" href="http://ionicframework.com/"> Ionic Framework Team< /author> < content src="https://www.songbingjia.com/android/index.html" /> < access origin="*" /> < allow-intent href="http://*/*" /> < allow-intent href="https://*/*" /> < allow-intent href="https://www.songbingjia.com/android/tel:*" /> < allow-intent href="https://www.songbingjia.com/android/sms:*" /> < allow-intent href="mailto:*" /> < allow-intent href="https://www.songbingjia.com/android/geo:*" /> < preference name="ScrollEnabled" value="https://www.songbingjia.com/android/false" /> < preference name="android-minSdkVersion" value="https://www.songbingjia.com/android/19" /> < preference name="BackupWebStorage" value="https://www.songbingjia.com/android/none" /> < preference name="SplashMaintainAspectRatio" value="https://www.songbingjia.com/android/true" /> < preference name="FadeSplashScreenDuration" value="https://www.songbingjia.com/android/300" /> < preference name="SplashShowOnlyFirstTime" value="https://www.songbingjia.com/android/false" /> < preference name="SplashScreen" value="https://www.songbingjia.com/android/screen" /> < preference name="SplashScreenDelay" value="https://www.songbingjia.com/android/3000" /> < platform name="android"> < edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"> < application android:networkSecurityConfig="@xml/network_security_config" /> < /edit-config> < resource-file src="https://www.songbingjia.com/android/resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" /> < allow-intent href="https://www.songbingjia.com/android/market:*" /> < icon density="ldpi" src="https://www.songbingjia.com/android/resources/android/icon/drawable-ldpi-icon.png" /> < icon density="mdpi" src="https://www.songbingjia.com/android/resources/android/icon/drawable-mdpi-icon.png" /> < icon density="hdpi" src="https://www.songbingjia.com/android/resources/android/icon/drawable-hdpi-icon.png" /> < icon density="xhdpi" src="https://www.songbingjia.com/android/resources/android/icon/drawable-xhdpi-icon.png" /> < icon density="xxhdpi" src="https://www.songbingjia.com/android/resources/android/icon/drawable-xxhdpi-icon.png" /> < icon density="xxxhdpi" src="https://www.songbingjia.com/android/resources/android/icon/drawable-xxxhdpi-icon.png" /> < splash density="land-ldpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-land-ldpi-screen.png" /> < splash density="land-mdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-land-mdpi-screen.png" /> < splash density="land-hdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-land-hdpi-screen.png" /> < splash density="land-xhdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-land-xhdpi-screen.png" /> < splash density="land-xxhdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-land-xxhdpi-screen.png" /> < splash density="land-xxxhdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-land-xxxhdpi-screen.png" /> < splash density="port-ldpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-port-ldpi-screen.png" /> < splash density="port-mdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-port-mdpi-screen.png" /> < splash density="port-hdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-port-hdpi-screen.png" /> < splash density="port-xhdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-port-xhdpi-screen.png" /> < splash density="port-xxhdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-port-xxhdpi-screen.png" /> < splash density="port-xxxhdpi" src="https://www.songbingjia.com/android/resources/android/splash/drawable-port-xxxhdpi-screen.png" /> < /platform> < platform name="ios"> < allow-intent href="https://www.songbingjia.com/android/itms:*" /> < allow-intent href="https://www.songbingjia.com/android/itms-apps:*" /> < icon height="57" src="https://www.songbingjia.com/android/resources/ios/icon/icon.png" width="57" /> < icon height="114" src="https://www.songbingjia.com/android/resources/ios/icon/icon@2x.png" width="114" /> < icon height="29" src="https://www.songbingjia.com/android/resources/ios/icon/icon-small.png" width="29" /> < icon height="58" src="https://www.songbingjia.com/android/resources/ios/icon/icon-small@2x.png" width="58" /> < icon height="87" src="https://www.songbingjia.com/android/resources/ios/icon/icon-small@3x.png" width="87" /> < icon height="20" src="https://www.songbingjia.com/android/resources/ios/icon/icon-20.png" width="20" /> < icon height="40" src="https://www.songbingjia.com/android/resources/ios/icon/icon-20@2x.png" width="40" /> < icon height="60" src="https://www.songbingjia.com/android/resources/ios/icon/icon-20@3x.png" width="60" /> < icon height="48" src="https://www.songbingjia.com/android/resources/ios/icon/icon-24@2x.png" width="48" /> < icon height="55" src="https://www.songbingjia.com/android/resources/ios/icon/icon-27.5@2x.png" width="55" /> < icon height="29" src="https://www.songbingjia.com/android/resources/ios/icon/icon-29.png" width="29" /> < icon height="58" src="https://www.songbingjia.com/android/resources/ios/icon/icon-29@2x.png" width="58" /> < icon height="87" src="https://www.songbingjia.com/android/resources/ios/icon/icon-29@3x.png" width="87" /> < icon height="40" src="https://www.songbingjia.com/android/resources/ios/icon/icon-40.png" width="40" /> < icon height="80" src="https://www.songbingjia.com/android/resources/ios/icon/icon-40@2x.png" width="80" /> < icon height="120" src="https://www.songbingjia.com/android/resources/ios/icon/icon-40@3x.png" width="120" /> < icon height="88" src="https://www.songbingjia.com/android/resources/ios/icon/icon-44@2x.png" width="88" /> < icon height="50" src="https://www.songbingjia.com/android/resources/ios/icon/icon-50.png" width="50" /> < icon height="100" src="https://www.songbingjia.com/android/resources/ios/icon/icon-50@2x.png" width="100" /> < icon height="60" src="https://www.songbingjia.com/android/resources/ios/icon/icon-60.png" width="60" /> < icon height="120" src="https://www.songbingjia.com/android/resources/ios/icon/icon-60@2x.png" width="120" /> < icon height="180" src="https://www.songbingjia.com/android/resources/ios/icon/icon-60@3x.png" width="180" /> < icon height="72" src="https://www.songbingjia.com/android/resources/ios/icon/icon-72.png" width="72" /> < icon height="144" src="https://www.songbingjia.com/android/resources/ios/icon/icon-72@2x.png" width="144" /> < icon height="76" src="https://www.songbingjia.com/android/resources/ios/icon/icon-76.png" width="76" /> < icon height="152" src="https://www.songbingjia.com/android/resources/ios/icon/icon-76@2x.png" width="152" /> < icon height="167" src="https://www.songbingjia.com/android/resources/ios/icon/icon-83.5@2x.png" width="167" /> < icon height="172" src="https://www.songbingjia.com/android/resources/ios/icon/icon-86@2x.png" width="172" /> < icon height="196" src="https://www.songbingjia.com/android/resources/ios/icon/icon-98@2x.png" width="196" /> < icon height="1024" src="https://www.songbingjia.com/android/resources/ios/icon/icon-1024.png" width="1024" /> < splash height="480" src="https://www.songbingjia.com/android/resources/ios/splash/Default~iphone.png" width="320" /> < splash height="960" src="https://www.songbingjia.com/android/resources/ios/splash/Default@2x~iphone.png" width="640" /> < splash height="1024" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Portrait~ipad.png" width="768" /> < splash height="768" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Landscape~ipad.png" width="1024" /> < splash height="1125" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Landscape-2436h.png" width="2436" /> < splash height="1242" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Landscape-736h.png" width="2208" /> < splash height="2048" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" /> < splash height="1536" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" /> < splash height="2732" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" /> < splash height="2048" src="https://www.songbingjia.com/android/resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" /> < splash height="1136" src="https://www.songbingjia.com/android/resources/ios/splash/Default-568h@2x~iphone.png" width="640" /> < splash height="1334" src="https://www.songbingjia.com/android/resources/ios/splash/Default-667h.png" width="750" /> < splash height="2208" src="https://www.songbingjia.com/android/resources/ios/splash/Default-736h.png" width="1242" /> < splash height="2436" src="https://www.songbingjia.com/android/resources/ios/splash/Default-2436h.png" width="1125" /> < splash height="2732" src="https://www.songbingjia.com/android/resources/ios/splash/Default@2x~universal~anyany.png" width="2732" /> < /platform> < plugin name="cordova-plugin-whitelist" spec="1.3.3" /> < access origin="*.ionic.io"/> < access origin="*.openstreetmap.org"/> < plugin name="cordova-plugin-statusbar" spec="2.4.2" /> < plugin name="cordova-plugin-device" spec="2.0.2" /> < plugin name="cordova-plugin-splashscreen" spec="5.0.2" /> < plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" /> < plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" /> < /widget>

map.page.ts代码段
leafletMap() { // In setView add latLng and zoom this.map = new L.Map('mapId').setView([this.lat,this.long], 9); L.tileLayer('/uploads/allimg/220519/13562H421-2.jpg', { attribution: 'edupala.com ? ionic LeafLet', }).addTo(this.map); }

mapId.div摘自map.html< div id="mapId" style="width: 100%; height: 60%">
我的离子环境如下
Ionic:Ionic CLI: 5.4.13 (C:Users iley.griceAppDataRoaming pm ode_modulesionic) Ionic Framework: @ionic/angular 4.11.7 @angular-devkit/build-angular : 0.803.21 @angular-devkit/schematics: 8.1.3 @angular/cli: 8.1.3 @ionic/angular-toolkit: 2.1.1Capacitor:Capacitor CLI: 1.4.0 @capacitor/core : 1.4.0Cordova:Cordova CLI: 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : android 8.1.0 Cordova Plugins: cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, cordova-plugin-android-permissions 1.0.2, cordova-plugin-camera 4.1.0, cordova-plugin-compat 1.2.0, cordova-plugin-device 2.0.2, cordova-plugin-flashlight 3.2.0, cordova-plugin-geolocation 4.0.2, cordova-plugin-splashscreen 5.0.2, cordova-plugin-statusbar 2.4.3, cordova-plugin-whitelist 1.3.4Utility:cordova-res: not installed native-run (update available: 0.3.0) : 0.2.9System:Android SDK Tools : 26.1.1 (C:Users iley.griceAppDataLocalAndroidSdk) NodeJS: v12.13.1 (C:Program Files odejs ode.exe) npm: 6.13.1 OS: Windows 10

答案我找到了解决方案。在华为手机上并尝试显示外部来源的地图图块时,它需要在HTTP URL上使用https URL,而与三星不同,华为设备将拒绝该来源。我只是将http更改为https,并且无需任何其他代码更改即可访问tile源。

    推荐阅读