quentinlampin / ngx-openlayers

Angular2+ components for Openlayers 4.x
Mozilla Public License 2.0
137 stars 98 forks source link

Blank map in a fresh angular-cli generated app #28

Closed quentin-ol closed 7 years ago

quentin-ol commented 7 years ago

Hey,

I've updated angular-cli to 1.0.0-beta.24 and tried created a fresh app using the latest AOT compatible version (0.4.2). I ran the usual:

ng init
npm install --save angular2-openlayers

then I imported the angular2-openlayers module in app.module.ts:

[...]
import { AngularOpenlayersModule } from 'angular2-openlayers';
[...]
imports: [
[...]
AngularOpenlayersModule
  ],
[...]

and put together this simple example in app.component.html:

<div>
    <aol-map>
        <aol-layer-tile>
            <aol-source-osm></aol-source-osm>
        </aol-layer-tile>
    </aol-map>
</div>

Running ng serve throws a dump of errors:

ERROR in Error encountered resolving symbol values statically. Calling function 'makeParamDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in /path/to/fresh_app/node_modules/angular2-openlayers/node_modules/@angular/core/src/di/metadata.d.ts, [...]

Since it seemed to have something with the angular package in angular2-openlayers/node_modules, I deleted it


rm -rf /path/to/fresh_app/node_modules/angular2-openlayers/node_modules/@angular
```.
```ng serve``` no longer throws errors at me, everything seems to run fine but the map doesn't show up despite logs in the console that tells me components are correctly instantiated.

Any idea why this is happening ?
On a side note, this move to AOT is raising quite a few concerns in angular-cli issues tracker right now.
quentin-ol commented 7 years ago

this might be related to #19. @FallenRiteMonk mentioned having a blank map issue as well.

FallenRiteMonk commented 7 years ago

I have the same problem here since angular-cli beta 24. I get the same error you mentioned running ng serve --aot, just running ng serve i get: ERROR in Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol NgModule in ... but still everything seems to be working just fine.

I'll have a look at it and give my best, but I don't know if I'm going to be able to fix it before the holidays.

quentin-ol commented 7 years ago

Thanks for the help, also investigating it right now.

FallenRiteMonk commented 7 years ago

Currently I think it has to do with the angular version itself. Cli bet 24 started using ^2.3.1, maybe try upgrading the library to the same version, or maybe even 2.4.0 and see if that helps! I have to leave now otherwise I would try myself.

FallenRiteMonk commented 7 years ago

I think it would be best to move all library dependencies to devDependencies in order to prevent such errors in future. Maybe only the angular packages, but since a user has to install openlayers anyway for the styling (due to #8), we could also just move it and write it into the README. @quentin-ol what do you think?

quentin-ol commented 7 years ago

Regarding the issue discussed above, this example lacks an component. The ol.Map doesn't fetch the tiles which, according to the specification, is the expected behaviour (http://openlayers.org/en/latest/apidoc/ol.Map.html). In short, my bad.

Regarding the other issue, i.e. angular-cli versions, this pertains to another issue. Closing this one for now.