添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am trying to use the AnimatedCluster. The code builds but I get a runtime error when I try to add the AnimatedCluster layer into my map: ERROR TypeError: a.dg is not a function

Here is the link to the details I've posted on Stackoverflow but have gotten no responses for:

https://stackoverflow.com/questions/54371557/getting-runtime-error-when-using-ol-ext-animatedcluster-in-typescript-app

Let's try an answer but I'm unsure. I could be wrong. Your issue is related to the fact you are using Typescript type verification in a code (ol-ext) that does not manage Typescript. Your issue is related to your Typescript not to the lib IMHO.

A guess would be that you are mixing npm openlayers package (e.g import * as ol from 'openlayers'; )
with ol-ext (e.g import AnimatedCluster from 'ol-ext/layer/AnimatedCluster'; ).
ol-ext expects you to use in webpack the npm ol package instead of the npm openlayers package.
In npm openlayers package a layer is new ol.layer.Tile(); whereas in npm ol package, a layer is new TileLayer(); . The difference for the type = one is namespaced, the other not. You may look at a project using ol-ext and ol in a webpack context: no namespace.

As @ThomasG77 says you can't mix the ES6 modules of ol-ext with openlayers: ol-ext depends on ol ES6 modules not on openlayers classes.
You have to use: ol + ol-ext
or: openlayers + openlayers-ext

Width modules:

import Map from 'ol/Map.js';
import View from 'ol/View.js';
// ol-ext
import AnimatedCluster from 'ol-ext/layer/AnimatedCluster';
// and then
let clusterLayer = AnimatedCluster({
    name: 'Cluster',
    source: clusterSource,
    animationDuration: 0,
    visible: true
});

or without:

import * as ol from 'openlayers';
import 'ol-ext';
// and then
let clusterLayer = new ol.layer.AnimatedCluster({
    name: 'Cluster',
    source: clusterSource,
    animationDuration: 0,
    visible: true
});

NB: as Openlayers classes are deprecated (npm 4.6.5 vs [email protected]), I recommand to use the ol package instead.

That worked for getting the AnimatedCluster working. Thank you!! I'm still having an issue with the SelectCluster and ConvexHull used to do the animation. I am currently not using jQuery and from what I have read, if I'm not using ol-ext prior to v3.1 (which is the case), then it should not be an issue. It looks like it might be the same issue I was having before with AnimatedCluster. I do not see those two classes in @types/ol-ext but I do see them in node_modules\ol-ext\interaction and node_modules\ol-ext\geom. I apologize if these are very basic questions. I very new to all of this and am still trying to find my way thru it all.