【问题标题】:Ionic 4 Google Maps plugin "failed to load optimized model at path..."Ionic 4 Google Maps 插件“无法在路径加载优化模型......”
【发布时间】:2019-06-05 02:09:45
【问题描述】:

插件在浏览器中工作,但在 ios 上

CoreData: annotation:  Failed to load optimized model at path '/Users/[User]/Library/Developer/CoreSimulator/Devices/FABE7039-7D5D-4AAB-B4D8-3D688FCEE930/data/Containers/Bundle/Application/7DA1B2E1-0DE6-4A89-8604-0EC160298BD8/[APP-NAME].app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
CoreData: annotation:  Failed to load optimized model at path '/Users/[User]/Library/Developer/CoreSimulator/Devices/FABE7039-7D5D-4AAB-B4D8-3D688FCEE930/data/Containers/Bundle/Application/7DA1B2E1-0DE6-4A89-8604-0EC160298BD8/[APP-NAME].app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
CoreData: annotation:  Failed to load optimized model at path '/Users/[User]/Library/Developer/CoreSimulator/Devices/FABE7039-7D5D-4AAB-B4D8-3D688FCEE930/data/Containers/Bundle/Application/7DA1B2E1-0DE6-4A89-8604-0EC160298BD8/[APP-NAME].app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'

我试过了:

  1. 在 config.xml、package.json 中包含 API 密钥,通过 app.component 在环境中设置

  2. 尝试删除 StorageWithTileProto.omo

  3. 更新了 google-maps 插件版本

在 app.component.ts 中

import { Environment } from '@ionic-native/google-maps/ngx';

...

 initializeApp() {
    this.platform.ready().then(() => {
       Environment.setEnv({
          'API_KEY_FOR_BROWSER_DEBUG': "[API_KEY]",
          'API_KEY_FOR_BROWSER_RELEASE': "[API_KEY]",
          "API_KEY_FOR_IOS": "[API_KEY]",
          "API_KEY_FOR_ANDROID": "[API_KEY]",
        });
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      this.authService.getToken();
      this.getUserData()
    });
  }

在 config.xml 中

...
<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="[API_KEY]" />
<preference name="GOOGLE_MAPS_IOS_API_KEY" value="[API_KEY]" />

...

<plugin name="cordova-plugin-googlemaps" spec="https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps">
    <variable name="PLAY_SERVICES_VERSION" value="15.0.1" />
    <variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>

在 map.component.ts 中

import {
  GoogleMaps,
  GoogleMap,
  GoogleMapsEvent,
  GoogleMapOptions,
  CameraPosition,
  MarkerOptions,
  Marker,
  Environment
} from '@ionic-native/google-maps/ngx';

...

constructor(
    public locationService: LocationService,
    private platform: Platform,
    private geolocation: Geolocation,
  ) { }

  async ngOnInit() {
    await this.platform.ready();
    await this.getUserLocation();
    await this.loadMap();
  }

  loadMap() {
    this.map = GoogleMaps.create('map_canvas', {
      camera: {
        target: {
          lat: 43.0741704,
          lng: -89.3809802
        },
        zoom: 18,
        tilt: 30
      }
    });
  }

预期:地图显示在 ios 设备上

实际:没有渲染地图,甚至没有空白地图

【问题讨论】:

    标签: ios google-maps cordova-plugins ionic4 xcode10.1


    【解决方案1】:

    原来是地图WAS渲染,但是在页面背景后面。将背景设置为透明的固定问题。出现的错误是不相关且非破坏性的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-19
      • 2015-12-16
      • 2018-04-03
      • 2019-03-01
      • 2018-04-04
      • 2019-11-16
      • 1970-01-01
      相关资源
      最近更新 更多