Comments (6)
next-transpile-modules should solve this issue with Next.js.
Add this to next.config.js
:
const withTM = require('next-transpile-modules')([
'@flowmap.gl/layers',
'@flowmap.gl/data',
]);
module.exports = withTM({
// ... rest of the config
});
from flowmap.gl.
Hi @ilyabo thanks for the response.
I've tried the code as you've indicated and it still don't works. I've tried also with different versions of the library with the same result.
Any ideas?
Thank you for your time and this great software.
from flowmap.gl.
Could you share your repo?
from flowmap.gl.
I can't because it's a corporate repo. But I'll try to share the relevant parts:
next.base.config.js
const withTM = require('next-transpile-modules')([
'@flowmap.gl/layers',
'@flowmap.gl/data'
]);
const nextConfig = {
nx: {
// Set this to true if you would like to to use SVGR
// See: https://github.com/gregberge/svgr
svgr: false
},
typescript: {
ignoreBuildErrors: true,
exportTrailingSlash: true,
generateEtags: false
}
};
module.exports = withTM({
...nextConfig,
reactStrictMode: true,
});
export default nextConfig;
package.json
...
"next": "12.0.3",
"@flowmap.gl/data": "^8.0.0-alpha.25",
"@flowmap.gl/layers": "^8.0.0-alpha.25",
"deck.gl": "^8.6.3",
"d3": "^7.1.1",
...
In my component I have:
// imports
type LocationDatum = {
id: string;
name: string;
lon: number;
lat: number;
};
type TooltipState = {
position: { left: number; top: number };
content: ReactNode;
};
type FlowDatum = {
origin: string;
dest: string;
value: number;
};
const ODMatrix = ({
api,
title,
data: unused = '',
width = 600,
height = 500
}) => {
const ICON_MAPPING = {
marker: { x: 0, y: 0, width: 128, height: 128, mask: true }
};
const [data, setData] = useState<FlowmapData<LocationDatum, FlowDatum>>();
const [viewStateModel, setViewStateModel] = useState({
latitude: 0,
longitude: 0,
zoom: 0,
bearing: 0,
pitch: 0,
width,
height
});
const { isSuccess, data: projectData }: any = useQuery(...)
useEffect(() => {
if (isSuccess) {
console.log('projectData', projectData, 'data', unused);
const locations = projectData?.map((feature) => {
return {
id: feature.id,
name: feature.name,
lon: feature.lon,
lat: feature.lat
};
});
console.log('OOH locations', locations);
const viewState = getViewStateForLocations(
locations,
(loc) => [loc.lon, loc.lat],
[width, height],
);
setViewStateModel({
...viewState,
latitude: viewState.latitude - 0.02,
zoom: viewState.zoom + 1,
});
}
}, [projectData]);
const layers = [
new FlowmapLayer<LocationDatum, FlowDatum>({
id: 'my-flowmap-layer',
od_data,
pickable: true
})
]
return (
<div>
{isSuccess ? (
<DeckGL
width={width}
height={height}
onViewStateChange={({ viewState }) => setViewStateModel(viewState)}
controller={false}
layers={layers}
>
<StaticMap
mapStyle={BASEMAP.POSITRON}
mapboxApiAccessToken={process.env.NEXT_PUBLIC_MAP}
/>
</DeckGL>
) : (
<div>Loading...</div>
)}
</div>
);
};
But I've never been able to test if the component works. After your suggestion the error I get is:
Error: require() of ES Module /Users/.../node_modules/d3-array/src/index.js from /Users/.../node_modules/@deck.gl/carto/dist/es5/api/layer-map.js not supported.
Instead change the require of index.js in /Users/.../node_modules/@deck.gl/carto/dist/es5/api/layer-map.js to a dynamic import() which is available in all CommonJS modules.
Thanks for your help.
from flowmap.gl.
Ah, so now you are getting the error because of @deck.gl/carto
which you probably don't need. Try listing in package.json
only the relevant parts of deck.gl: @deck.gl/core, @deck.gl/layers, @deck.gl/react. Or alternatively, try adding @deck.gl/carto
to next-transpile-modules
from flowmap.gl.
I'll do. Thanks!
from flowmap.gl.
Related Issues (13)
- Issues trying to get webpack example running HOT 8
- Installation HOT 1
- Fetching all the children of a picked node or link HOT 2
- this.accessors.getLocationCentroid is not a function at FlowMapAggregateAccessors.getLocationCentroid (FlowMapAggregateAccessors.js?3933:20:1) HOT 4
- dataProvider.updateLayersData is not a function HOT 4
- Force flow line to always display ? HOT 1
- Custom location colors HOT 1
- Timeline react component library.
- Importing error HOT 2
- @flowmap.gl/data latest vertion not match HOT 4
- clusteringEnabled:false error HOT 5
- [Feat] Add force directed flow paths HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flowmap.gl.