fegyi001 / mangol

Maps created with Angular & OpenLayers using Material design
http://188.166.116.137/mangol/
98 stars 47 forks source link

ReferenceError: ol is not defined #1

Closed Sicrum closed 7 years ago

Sicrum commented 7 years ago

Hello

I am trying to setup mangol in our angular2 project. We are using webpack to build clientside bundles. But we don't ue angular-cli, so there is no angular-cli.json file.

In vendor.browser.ts I have added lines:

import "openlayers/dist/ol.js";
import "proj4/dist/proj4.js";
import "jspdf/dist/jspdf.min.js";

And I see it in rendered vendor.js : https://www.screencast.com/t/Gweemn0oquW6 However I am getting this exception:

error_handler.js:46 EXCEPTION: Uncaught (in promise): ReferenceError: ol is not defined ErrorHandler.handleError @ error_handler.js:46 next @ application_ref.js:298 schedulerFn @ async.js:89 SafeSubscriber.__tryOrUnsub @ Subscriber.js:223 SafeSubscriber.next @ Subscriber.js:172 Subscriber._next @ Subscriber.js:125 Subscriber.next @ Subscriber.js:89 Subject.next @ Subject.js:55 EventEmitter.emit @ async.js:81 onError @ ng_zone.js:123 onHandleError @ ng_zone_impl.js:65 ZoneDelegate.handleError @ zone.js:207 Zone.runGuarded @ zone.js:113 _loop_1 @ zone.js:379 drainMicroTaskQueue @ zone.js:386 error_handler.js:51 ORIGINAL STACKTRACE: ErrorHandler.handleError @ error_handler.js:51 next @ application_ref.js:298 schedulerFn @ async.js:89 SafeSubscriber.__tryOrUnsub @ Subscriber.js:223 SafeSubscriber.next @ Subscriber.js:172 Subscriber._next @ Subscriber.js:125 Subscriber.next @ Subscriber.js:89 Subject.next @ Subject.js:55 EventEmitter.emit @ async.js:81 onError @ ng_zone.js:123 onHandleError @ ng_zone_impl.js:65 ZoneDelegate.handleError @ zone.js:207 Zone.runGuarded @ zone.js:113 _loop_1 @ zone.js:379 drainMicroTaskQueue @ zone.js:386 error_handler.js:52 Error: Uncaught (in promise): ReferenceError: ol is not defined at resolvePromise (http://localhost:53490/polyfills.bundle.js:7444:31) at http://localhost:53490/polyfills.bundle.js:7421:13 at ZoneDelegate.invoke (http://localhost:53490/polyfills.bundle.js:7218:28) at Object.onInvoke (http://localhost:53490/vendor.bundle.js:36760:37) at ZoneDelegate.invoke (http://localhost:53490/polyfills.bundle.js:7217:34) at Zone.run (http://localhost:53490/polyfills.bundle.js:7111:43) at http://localhost:53490/polyfills.bundle.js:7477:57 at ZoneDelegate.invokeTask (http://localhost:53490/polyfills.bundle.js:7251:37) at Object.onInvokeTask (http://localhost:53490/vendor.bundle.js:36751:37)

Do you have any ideas?

Thanks. Renat

fegyi001 commented 7 years ago

This is now fixed. OpenLayers was needed to import as a module. Thanks!