quentinlampin / ngx-openlayers

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

Cannot read property 'prototype' of undefined #4

Closed FallenRiteMonk closed 7 years ago

FallenRiteMonk commented 7 years ago

Importing the Module leads the following error:

EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'prototype' of undefined

The error seems to be thrown on the following line of the feature component:

d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());

to be preciser it's line 5 possition 69

Thank you

quentin-ol commented 7 years ago

I can't reproduce your error. Could you provide a minimal example that reproduces the error ?

Here is an example that works for me: in app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AngularOpenlayersModule } from 'angular2-openlayers';
import { AppComponent } from './app.component';

@NgModule({
  declarations:  [ AppComponent ],
  imports: [ BrowserModule, AngularOpenlayersModule ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

in app.component.ts:

import { Component } from '@angular/core';
import { MapComponent, ViewComponent, LayerTileComponent, LayerVectorComponent, 
          SourceOsmComponent, SourceVectorComponent, FeatureComponent,
          GeometryPointComponent, GeometryLinestringComponent, 
          CoordinateComponent, CollectionCoordinatesComponent } from 'angular2-openlayers';

@Component({
  selector: 'app-root',
  template: `
  <h1>Angular2-openlayers example</h1>
  <div style='height:300px'>
      <aol-map>
        <aol-view zoom="13">
          <aol-coordinate [x]="5" [y]="45" [srid]="'EPSG:4326'"></aol-coordinate>
        </aol-view>
         <aol-layer-tile>
            <aol-source-osm></aol-source-osm>
        </aol-layer-tile>
          <aol-layer-vector>
            <aol-source-vector>
                <aol-feature>
                    <aol-geometry-point>
                        <aol-coordinate [x]="5" [y]="45" [srid]="'EPSG:4326'"></aol-coordinate>
                    </aol-geometry-point>
                </aol-feature>
            </aol-source-vector>
          </aol-layer-vector>
      </aol-map>
   </div>`
})
export class AppComponent {}

in index.html:

<body>
  <app-root>Loading...</app-root>
</body>
FallenRiteMonk commented 7 years ago

I figured out what was the problem, it was due to a second import of openlayers that I already had, so removing that fixed the problem.

But would you please be so kind and putt the example in your readme file, that would already help.

Thanks

FallenRiteMonk commented 7 years ago

And your imports in the app component are not needed! You can remove them and your example still works!

quentin-ol commented 7 years ago

@FallenRiteMonk Thanks for the feedback, I will add this short example to the readme. Can I close this issue ?