Home > Mobile >  Uncaught (in promise) ReferenceError: topojson is not defined
Uncaught (in promise) ReferenceError: topojson is not defined

Time:09-22

I'm new at d3. I can't render a US map, could you have a look?

https://codepen.io/DeanWinchester88/pen/BaZYewv

d3.json(COUNTIES)
  .then( data =>  {
   let  states = topojson.feature(data, data.objects.states);
 

CodePudding user response:

TopoJSON was never part of any D3 bundle. Therefore, you have to reference it, like:

<script src="https://unpkg.com/topojson@3"></script>

In the CodePen, "Add Package" will create:

import * as topojson from "https://cdn.skypack.dev/[email protected]"; 

(and now you'll have brand new errors...)

  • Related