My project name is googlemaps-heremaps-iframe.
How do I run import { decode } from ‘@here/flexpolyline’; in script.js?
I tried setting up webpack.config.js but npm run build failed due to webpack.flatmap is not a function.
My project name is googlemaps-heremaps-iframe.
How do I run import { decode } from ‘@here/flexpolyline’; in script.js?
I tried setting up webpack.config.js but npm run build failed due to webpack.flatmap is not a function.
if im not wrong, couldn’t you do var decodedpath = decode(polyline);
?
I can’t recreate the error youre facing. Could you give some brief steps to reproduce this?
Map with 3 points
In the link, I have point 1,2,7 populated and shown on the map. There should be a route connecting those points.
You can see that the polyline was given in the console but it could not be decoded.
Where is the flexpolyline package located originally?
Here is the original GitHub - heremaps/flexible-polyline: Flexible Polyline encoding: a lossy compressed representation of a list of coordinate pairs or triples.
I manually downloaded the package and add it to my file as a workaround. But I would still like to know how to import npm in Glitch.
as long as there’s a published NPM package for it, you can click on your package.json file in the file tree and then click the “+ add package” button in the upper right of the editor. It looks like there’s two packages by that name according to npm:
Once installed, if you’re running a build task the import should work “normally”, if you’re not then you’ll need to copy the file from its node_modules location into your project’s static content directory so it can be loaded client-side.
Note that Glitch does not support the latest version of Node at the moment (see https://help.glitch.com/hc/en-us/articles/16287495688845-What-version-of-Node-can-I-use-and-how-do-I-change-update-upgrade-it) so you may need to use an older version of webpack, although I’d strongly recommend using https://esbuild.github.io/ instead: it’s much faster and for normal bundling you can just run it as normal CLI command (e.g. as npm script) instead of needing config files.