I followed exactly steps in Getting Started, however I got error during page load and the maps cannot be load.
Steps to reproduce
1) Install agm core module through terminal
npm install @agm/core --save
2) Include AgmCoreModule in app.module.ts
```
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AgmCoreModule } from '@agm/core';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AgmCoreModule.forRoot({
apiKey : 'my_api_key'
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
```
3) Add <agm-map />
component in my html
```
<agm-map [latitude]="latitude" [longitude]="longitude">
</agm-map>
```
4) Add height to <agm-map />
component in my app.component.scss
agm-map {
height : 600px;
}
5) Add latitude
and longitude
property in app.component.ts
```
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
latitude: number = 51.678418;
longitude: number = 7.809007;
constructor(){}
}
```
6) Run the application using ng serve
command
7) Open http://localhost:4200
in my browser just to see blank page with below's error in developer console.
ERROR TypeError: Object(...) is not a function
at new FitBoundsService (fit-bounds.js:31)
at createClass (core.js:12481)
at _createProviderInstance (core.js:12458)
at createProviderInstance (core.js:12299)
at createViewNodes (core.js:13771)
at callViewAction (core.js:14218)
at execComponentViewsAction (core.js:14127)
at createViewNodes (core.js:13812)
at createRootView (core.js:13673)
at callWithDebugContext (core.js:15098)
Expected/desired behavior
I want to display a map without any marker in it.
angular2 & angular-google-maps version
Angular CLI: 1.6.8
Node: 9.5.0
OS: linux x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
AGM Version : @agm/[email protected]
Same thing here in angular 6. It stopped working in beta 4; beta 3 still works as it should.
Same here.
When i look at the source map, for me it's throwing an error at line 31 where it's setting this.bounds$
within the FitBoundsService
constructor.
import { Injectable } from '@angular/core';
import { BehaviorSubject, from, timer } from 'rxjs';
import { flatMap, map, sample, switchMap, shareReplay } from 'rxjs/operators';
import { MapsAPILoader } from './maps-api-loader/maps-api-loader';
/**
* Class to implement when you what to be able to make it work with the auto fit bounds feature
* of AGM.
*/
var /**
* Class to implement when you what to be able to make it work with the auto fit bounds feature
* of AGM.
*/
FitBoundsAccessor = /** @class */ (function () {
function FitBoundsAccessor() {
}
return FitBoundsAccessor;
}());
/**
* Class to implement when you what to be able to make it work with the auto fit bounds feature
* of AGM.
*/
export { FitBoundsAccessor };
/**
* The FitBoundsService is responsible for computing the bounds of the a single map.
*/
var FitBoundsService = /** @class */ (function () {
function FitBoundsService(loader) {
var _this = this;
this._boundsChangeSampleTime$ = new BehaviorSubject(200);
this._includeInBounds$ = new BehaviorSubject(new Map());
this.bounds$ = from(loader.load()).pipe(flatMap(function () { return _this._includeInBounds$; }), sample(this._boundsChangeSampleTime$.pipe(switchMap(function (time) { return timer(0, time); }))), map(function (includeInBounds) { return _this._generateBounds(includeInBounds); }), shareReplay(1));
}
FitBoundsService.prototype._generateBounds = function (includeInBounds) {
var bounds = new google.maps.LatLngBounds();
includeInBounds.forEach(function (b) { return bounds.extend(b); });
return bounds;
};
FitBoundsService.prototype.addToBounds = function (latLng) {
var id = this._createIdentifier(latLng);
if (this._includeInBounds$.value.has(id)) {
return;
}
var map = this._includeInBounds$.value;
map.set(id, latLng);
this._includeInBounds$.next(map);
};
FitBoundsService.prototype.removeFromBounds = function (latLng) {
var map = this._includeInBounds$.value;
map.delete(this._createIdentifier(latLng));
this._includeInBounds$.next(map);
};
FitBoundsService.prototype.changeFitBoundsChangeSampleTime = function (timeMs) {
this._boundsChangeSampleTime$.next(timeMs);
};
FitBoundsService.prototype.getBounds$ = function () {
return this.bounds$;
};
FitBoundsService.prototype._createIdentifier = function (latLng) {
return latLng.lat + "+" + latLng.lng;
};
FitBoundsService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
FitBoundsService.ctorParameters = function () { return [
{ type: MapsAPILoader, },
]; };
return FitBoundsService;
}());
export { FitBoundsService };
//# sourceMappingURL=fit-bounds.js.map
// WEBPACK FOOTER //
// ./node_modules/@agm/core/services/fit-bounds.js.pre-build-optimizer.js
@agm/[email protected]
does work fine with Angular 6.0.0 however.
We also experienced the same error. Previously had "@agm/core": "^1.0.0-beta.2" which was installing "@agm/[email protected]" but recently has been installing "@agm/[email protected]". Which broke our site.
Changing the package.json to specify exact version is our workaround for now. "@agm/core": "1.0.0-beta.3".
Since you are creating Angular: 5 application :
Angular: 5.2.11
RxJS 5.x
package is installed with it.
But starting from @agm/[email protected]
the library has a dependency to RxJS 6.x
, that's the reason why this error occurs.
So, the solution would to update RxJS from from 5.x to 6.x:
npm uninstall rxjs
npm install rxjs@6 rxjs-compat@6 --save
@vgrem I was facing the same issue. Yours reply worked for me. Thanx much
@vgrem work for me
@vgrem Thank you, work for me.
Try this. 'npm i agm-core'. It works fine for me
@vgrem Thanks !!!
Thank you @vgrem
your solution is great, very fine
npm uninstall rxjs
npm install rxjs@6 rxjs-compat@6 --save
it's work very wel for me.
Since you are creating Angular: 5 application :
Angular: 5.2.11
RxJS 5.x
package is installed with it.But starting from
@agm/[email protected]
the library has a dependency toRxJS 6.x
, that's the reason why this error occurs.So, the solution would to update RxJS from from 5.x to 6.x:
npm uninstall rxjs npm install rxjs@6 rxjs-compat@6 --save
Thank you !!!
Didn't work for me. I installed rxjs@6 and rxjs-compat@6, but now I have more errors in console:
ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.
I have @agm/core 1.0.0-beta.5 and @angular/core 5.2.11
Help!
thank you sebastian, very good.
Le ven. 1 févr. 2019 à 18:44, GioPetrucci notifications@github.com a
écrit :
Didn't work for me. I installed rxjs@6 and rxjs-compat@6, but now I have
more errors in console:ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.I have @agm/core 1.0.0-beta.5 and @angular/core 5.2.11
Help!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/SebastianM/angular-google-maps/issues/1511#issuecomment-459805906,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AsaAFdzd4L72QRQR6xX82u9UTBqZi_TTks5vJHzzgaJpZM4W8OOM
.
Since you are creating Angular: 5 application :
Angular: 5.2.11
RxJS 5.x package is installed with it.
But starting from @agm/[email protected] http://url/ the library has a
dependency to RxJS 6.x, that's the reason why this error occurs.
So, the solution would to update RxJS from from 5.x to 6.x
https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md
:
npm uninstall rxjs
npm install rxjs@6 rxjs-compat@6 --save
Le sam. 2 févr. 2019 à 09:24, Fouejio Georges legrandgeorges754@gmail.com
a écrit :
thank you sebastian, very good.
Le ven. 1 févr. 2019 à 18:44, GioPetrucci notifications@github.com a
écrit :Didn't work for me. I installed rxjs@6 and rxjs-compat@6, but now I have
more errors in console:ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.I have @agm/core 1.0.0-beta.5 and @angular/core 5.2.11
Help!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/SebastianM/angular-google-maps/issues/1511#issuecomment-459805906,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AsaAFdzd4L72QRQR6xX82u9UTBqZi_TTks5vJHzzgaJpZM4W8OOM
.
Didn't work for me. I installed rxjs@6 and rxjs-compat@6, but now I have more errors in console:
ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.
I have @agm/core 1.0.0-beta.5 and @angular/core 5.2.11
Help!
Same here!
may be, you have a syntax error. check your code very well
RROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005:
';' expected.
i'm seeing that << ';' expected. >>, check your syntax because Angular
like soft code.
if the Error persist, tell me again
Le ven. 8 févr. 2019 à 13:18, Alessandro Oliveira Silva <
[email protected]> a écrit :
Didn't work for me. I installed rxjs@6 and rxjs-compat@6, but now I have
more errors in console:ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.I have @agm/core 1.0.0-beta.5 and @angular/core 5.2.11
Help!
Same here!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/SebastianM/angular-google-maps/issues/1511#issuecomment-461785390,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AsaAFcrrjl40kD5DQkAsAU1hciR5kbjIks5vLWsLgaJpZM4W8OOM
.
@joker7blue any workaround?
I think you used the dependency in package.json like this :
"@agm/core": "^1.0.0-beta.2"
When you use ^
... npm will optimize your dependency, trying to keep the package up-to-date until this package is compatible with the others... but in this case the npm thinks wrong
I used this syntax and the npm installed the beta.5 .... You can check this if u search the agm folder in node_modules and open the agm's package.json.. there is a "version" key for it.
If I delete the ^
before the version number I force the npm to use this version and this solved my problem.
I hope it helps.
Yes i used "@agm/core": "1.0.0-beta.3"
and now it works.
Work for me also.
Thank you.
may be, you have a syntax error. check your code very well RROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected. i'm seeing that << ';' expected. >>, check your syntax because Angular like soft code. if the Error persist, tell me again Le ven. 8 févr. 2019 à 13:18, Alessandro Oliveira Silva < [email protected]> a écrit :
…
Didn't work for me. I installed @.* and @., but now I have more errors in console: ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected. I have @agm/core 1.0.0-beta.5 and @angular/core 5.2.11 *Help! Same here! — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1511 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AsaAFcrrjl40kD5DQkAsAU1hciR5kbjIks5vLWsLgaJpZM4W8OOM .
It uses "infer", which is introduced in TypeScript in 2.8. Update TypeScript version through package.json and npm install worked for me.
Closing, as no error in AGM.
Most helpful comment
Since you are creating Angular: 5 application :
RxJS 5.x
package is installed with it.But starting from
@agm/[email protected]
the library has a dependency toRxJS 6.x
, that's the reason why this error occurs.So, the solution would to update RxJS from from 5.x to 6.x: