I am working on an openlayers 3 project, developed using typescript, hence:
let ol = require("openlayers");
I would like to use the transform extension plugin, which is not published on NPM (http://viglino.github.io/ol3-ext/interaction/transforminteraction.js)
I tried the following:
let ol = require("openlayers");
require("<path>/ol/transforminteraction");
however I get the following errors:
ERROR TypeError: ol.interaction.Transform is not a constructor
and
Uncaught ReferenceError: ol is not defined
How am I able include/integrate this resource correctly?
let ol = require("openlayers");
This means ol is not in the global scope, therefore it isn't available to transforminteraction to extend.
Looking at the plugin code, you should be able to wrap it in a
module.exports = function(ol) {
...
}
This puts ol into the function scope.
Then you can use it by passing in ol as an argument to extend it. e.g.
let ol = require("openlayers");
require("<path>/ol/transforminteraction")(ol);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With