Hello,
I have an issue concerning the Google Maps Plugin (@capacitor/google-maps) and iOS. I followed the instructions in the Announcement.
Namely:
Installed the required packages:
npm install @capacitor/google-maps
npx cap sync
Updated the Info.plist file (/Users//project/ios/App/App/Info.plist). Set the following parameters:
<key>NSLocationAlwaysUsageDescription</key>
<string>Privacy We need your Location Always</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Privacy We need your Location when App is in usage</string>
When I start my application with the command Ionic capacitor run ios -l —external the simulator starts. Further, in my web-browser the map opens up if I press the button. But in my iOS-Environment it does not work. When I press the button, nothing happens and the map is not shown. Any suggestions? Thank you in advance!
The Google Maps SDK currently does not support running on simulators using the new M1-based Macbooks. This is a known and acknowledged issue and requires a fix from Google. If you are developing on a M1 Macbook, building and running on physical devices is still supported and is the recommended approach.
Okay here we go. I used my iPhone to launch the app on it and it still does not work. In my XCode output it says: To Native → CapacitorGoogleMaps create 8589184 TO JS undefined
when i click the button.
Does that output help me in any way?
The exact same thing is happening to me as well. I can see the map in the browser. I also get the same XCode output: TO JS undefined. I’ve enabled billing and enabled the javascript sdk and maps sdk for ios.
Im running it on my phone and my mac is one with Intel chip. Any help would be appreciated.
My colleague finally found the issue. When you use the plugin you need to import the CUSTOM_ELEMENTS_SCHEMA in every @NgModule-Schema that you use. See example below:
In my case I had to import it in my tab-map.module.ts and in my app.module.ts.
tab-map.module.ts
import { IonicModule } from '@ionic/angular';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { TabMapPage } from './tab-map.page';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TabMapPageRoutingModule } from './tab-map-routing.module';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
TabMapPageRoutingModule
],
declarations: [TabMapPage],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class TabMapPageModule {}
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@NgModule({
declarations: [
AppComponent,
],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}
I’m facing exactly the same problem. Importing CUSTOM_ELEMENTS_SCHEMA did not solve the problem for me. Did you change anything else besides the import?
IMO it’s cool that ionic finally created a plugin for google maps but it seems it’s effort is kind of late. And they are still implementing other most common maps features, which most of us cannot wait for.
So I found the capacitor google map plugin is not as easy to set up as is the official angular google maps component. This map component works well with native and web, does not need extra packages and works out the box.
Has anyone had any success with this issue - I’m stuck; I cannot get the map to appear in iOS device or simulator, but working properly in web. Haven’t tried Android. I get the same XCode output: “TO JS undefined”. I’ve added CUSTOM_ELEMENTS_SCHEMA in every module.