ionic-team / ionic-native-google-maps

Google maps plugin for Ionic Native
Other
221 stars 125 forks source link

Can't use ionic maps #98

Closed aadriann closed 5 years ago

aadriann commented 5 years ago

Hi, i have this error: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'environment' of null TypeError: Cannot read property 'environment' of null

i try ionic ionic cordova build browser -l, but no works.

I debug from GoogleMapsOriginal.getPlugin() and it's null.

Some idea?

Regards

Axdron commented 5 years ago

Same problem here

Axdron commented 5 years ago

I was using "ionic serve", that's the problem. I tried running by browser and worked.

aadriann commented 5 years ago

I use ionic cordova run browser -l when i debug this error. I read the docs before open this issue.

El sáb., 20 oct. 2018 15:37, Axdron notifications@github.com escribió:

I was using "ionic serve", that's the problem. You must use "ionic cordova run browser -l", as shown in documentation: https://docs.google.com/presentation/d/e/2PACX-1vScoho1ensbR4qCI9AIuQN55BZVvK73pAjI7sumDvW3CrxxHnrmpXWUjx2-8CpFibqU1EjLKCRhuthJ/pub?start=false&loop=false&delayms=3000&slide=id.g282d0a7bfd_0_158 , because of cordova.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-native-google-maps/issues/98#issuecomment-431582816, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkkOedz7GGKwMnfSJYExqo7DwZUvC9Fks5umyc2gaJpZM4Xx2Vf .

wf9a5m75 commented 5 years ago

@Axdron ionic serve is not supported. You must run with ionic cordova run browser.

@aadriann I think you forgot platform.ready() before the first plugin statement or you don't install cordova-plugin-googlemaps. If you can't solve the problem by yourself, please share your project files on github.

aadriann commented 5 years ago

Maybe i forgot install plugin. I work with ionic 4. My ngOnInit call paltform and my loadMap like this: async ngOnInit(){ await this.platform.ready(); await this.loadMap(); }

I will check if i install that plugin. Seems not appear in the documentation.

El sáb., 20 oct. 2018 18:07, Masashi Katsumata notifications@github.com escribió:

@Axdron https://github.com/Axdron ionic serve is not supported. You must run with ionic cordova run browser.

@aadriann https://github.com/aadriann I think you forgot platform.ready() before the first plugin statement or you don't install cordova-plugin-googlemaps. If you can't solve the problem by yourself, please share your project files on github.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-native-google-maps/issues/98#issuecomment-431594720, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkkOWenhZJoldpg_UDQzTYQTKJNV1qGks5um0ougaJpZM4Xx2Vf .

wf9a5m75 commented 5 years ago

https://docs.google.com/presentation/d/e/2PACX-1vScoho1ensbR4qCI9AIuQN55BZVvK73pAjI7sumDvW3CrxxHnrmpXWUjx2-8CpFibqU1EjLKCRhuthJ/pub?start=false&loop=false&delayms=3000&slide=id.g292c767148_0_47

aadriann commented 5 years ago

I was follow this guide, but th plugin doesn't works

Adrián Rincón López

El sáb., 20 oct. 2018 19:47, Masashi Katsumata notifications@github.com escribió:

https://docs.google.com/presentation/d/e/2PACX-1vScoho1ensbR4qCI9AIuQN55BZVvK73pAjI7sumDvW3CrxxHnrmpXWUjx2-8CpFibqU1EjLKCRhuthJ/pub?start=false&loop=false&delayms=3000&slide=id.g292c767148_0_47

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-native-google-maps/issues/98#issuecomment-431603734, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkkOVlv7cj_ozg6IOKGVcdyYi1Df70xks5um2GygaJpZM4Xx2Vf .

wf9a5m75 commented 5 years ago

As I said,

If you can't solve the problem by yourself, please share your project files on github

aadriann commented 5 years ago

Now i away, when i continue with the app, i share the component.

Thanks for the help.

El sáb., 20 oct. 2018 20:00, Masashi Katsumata notifications@github.com escribió:

As I said,

If you can't solve the problem by yourself, please share your project files on github

You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-native-google-maps/issues/98#issuecomment-431604777, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkkOcwuF6IvZfNLuwzPZ9NgLqa44v_-ks5um2TYgaJpZM4Xx2Vf .

aadriann commented 5 years ago

This is my code:

component where i want to use Google Maps:

import { Platform } from '@ionic/angular';
import { LodgingService } from './../providers/lodging/lodging.service';
import { Component, OnInit } from '@angular/core';
import { NotificationService } from
'../providers/notification/notification.service';
import { GoogleMaps, GoogleMap, GoogleMapOptions, GoogleMapsEvent, Marker,
Environment } from '@ionic-native/google-maps';

@Component({
selector: 'app-lodging-detail',
templateUrl: './lodging-detail.page.html',
styleUrls: ['./lodging-detail.page.scss'],
})
export class LodgingDetailPage implements OnInit {

lodging: any;
map: GoogleMap;
constructor(private _lodgingService: LodgingService, private
_notificationService: NotificationService, private _platform: Platform) { }

lodgingDetail() {
this._lodgingService.getLodgingDetail(this._lodgingService.
currentLodgingDetail)
.then(response => {
this.lodging = response;
})
.catch(error => {
this._notificationService.presentToast(error.statusText);
})
}

loadMap() {
Environment.setEnv({
'API_KEY_FOR_BROWSER_DEBUG': '',
'API_KEY_FOR_BROWSER_RELEASE': 'MY WEB API KEY'
});

let mapOptions: GoogleMapOptions = {
camera: {
target: {
lat: 43.0741904,
lng: -89.3809802
},
zoom: 18,
tilt: 30
}
};

this.map = GoogleMaps.create('map_canvas', mapOptions);

let marker: Marker = this.map.addMarkerSync({
title: 'Ionic',
icon: 'blue',
animation: 'DROP',
position: {
lat: 43.0741904,
lng: -89.3809802
}
});
marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe(() => {
alert('clicked');
});
}

async ngOnInit() {
this.lodgingDetail();
await this._platform.ready();
await this.loadMap();
}

}

app.module

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { HttpClientModule } from "@angular/common/http";
import { IonicStorageModule } from '@ionic/storage';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { PipesModule } from './pipes/pipes.module';

@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,
HttpClientModule, IonicStorageModule.forRoot(), PipesModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
wf9a5m75 commented 5 years ago

As I said

please share your project files on github

Don't past your part of code.

aadriann commented 5 years ago

I can't share all code, only i piece sorry

El dom., 21 oct. 2018 a las 16:03, Masashi Katsumata (< notifications@github.com>) escribió:

As I said

please share your project files on github

Don't past your part of code.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-native-google-maps/issues/98#issuecomment-431671525, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkkOQPylcZT35G6x1m-rJBRyN78q-3Uks5unH64gaJpZM4Xx2Vf .

wf9a5m75 commented 5 years ago

Then please debug by yourself.

wf9a5m75 commented 5 years ago

When you become a sick, you go to a doctor. Then you only describe your situation. But you decline to check your body by the doctor. The doctor can not determine what happens in your body.

It's the same. I can't determine what is wrong in your project without checking your whole project files. If you decline, then please debug by yourself.

aadriann commented 5 years ago

Masashi, i can't share it beacuse it's not mine, it's for a private. I would share it if it were mine. But thank you very much for your help.

El dom., 21 oct. 2018 a las 16:13, Masashi Katsumata (< notifications@github.com>) escribió:

When you become a sick, you go to a doctor. Then you only describe your situation. But you decline to check your body by the doctor. The doctor can not determine what happens in your body.

It's the same. I can't determine what is wrong in your project without checking your whole project files. If you decline, then please debug by yourself.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-native-google-maps/issues/98#issuecomment-431672352, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkkOb1aFF2JSDMr_h_lGS7WHoOAh0cNks5unIELgaJpZM4Xx2Vf .

wf9a5m75 commented 5 years ago

Good luck