Ionic 4 Google Maps插件“无法在路径上加载优化的模型...”

时间:2019-05-07 16:08:43

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

插件可以在浏览器中使用,但在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. 通过app.component在环境中设置的config.xml,package.json中包含的API密钥

  2. 试图删除StorageWithTileProto.omo

  3. 更新的Google地图插件版本

在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设备上显示的地图

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

1 个答案:

答案 0 :(得分:0)

显示地图WAS渲染,但在页面背景后面。将背景设置为透明的固定问题。出现的错误是无关且不间断的