2

I've been stuck on this problem for hours at this point and I can't figure out the problem.

I've been following http://bost.ocks.org/mike/map/ with my own data set.

The error: Uncaught TypeError: Cannot read property 'type' of undefined - topojson.v0.min.js:1

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>

path {
  fill: #ccc;
  stroke: #fff;
  stroke-width: .5px;
}

path:hover {
  fill: red;
}

</style>
</head>
<body>
<script src="../static/js/d3.min.js"></script>
<script src="../static/js/topojson.v0.min.js"></script>
<script>


var width = 900,
    height = 900;

var path = d3.geo.path();

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);


d3.json("../static/json/newjerseymun.json", function(nj) {
  svg.append("path")
      .datum(topojson.object(nj, nj.objects.subunits))
      .attr("d", d3.geo.path().projection(d3.geo.mercator()));
});

</script>

</body>

Here is a sample of the beginning of my json file: http://pastebin.com/g0Lut36V

1 Answer 1

3

The problem seems to be in the file ../static/json/newjerseymun.json.

The segment of the newjerseymin.json you have posted does have the field objects which contains a JSON object but there does not seem to be a subunits field in that object, not at least in the segment you have posted. Hence, ns.objects.subunits would be undefined which causes the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.