I am getting the following error when trying to run my Javascript file:
"Uncaught TypeError: Object function (a){"undefined"==typeof a&& a=0);this.m_PolyOuts=null;this.m_ClipType= d.ClipType.ctIntersection;this.m_IntersectNodeComparer=this.m_IntersectList=this.m_SortedEdges=this.m_ActiveEdges=this.m_Scanbeam=null;this.m...<omitted>...y'"
Relevant code:
<script>
// Geolocation
var stateData;
var states = new Object();
d3.json("states.json", function (data) {
stateData = data;
data.features.forEach(function (datum) {
// Populate data for each entry in states[__]...
});
var pt = new ClipperLib.IntPoint(67.007915, -152.002047);
for (var i = 0; i < states["Alaska"].length; ++i) {
var done = 0;
for (var j = 0; j < states["Alaska"][i].length; ++j) {
var poly = states["Alaska"][i][j];
if (ClipperLib.Clipper.PointInPoly(pt, poly) == 1) {
done = 1;
break;
}
...
}
}
...
});
</script>
When I try running the command on the console in Chrome, I do not receive an error: https://www.dropbox.com/s/cm29oaxgr5rjz2d/Screenshot%202014-02-28%2011.42.19.png
I am using ClipperJS and have at the top of my file included it as a src as such:
< script src="clipper.js" charset="utf-8">< /script>
(No spaces before "script" or "/script" - they are here because it would not display otherwise.)
I thought it might have been because of a type mismatch but I then tried:
...
var poly = [{X:10,Y:10},{X:110,Y:10},{X:110,Y:110},{X:10,Y:110}];
if (ClipperLib.Clipper.PointInPoly(pt, poly) == 1) {
done = 1;
break;
}
...
And I still got the same error. Any help is appreciated!
Relevant link for where I got the idea to use ClipperJS (answer by "Timo")