現在、Google Visualization APIを使用してヒートマップを作成するJavaScriptアプリケーションに取り組んでいますが、何らかの理由で、データの配列をヒートマップに追加するたびに、最後から2番目の要素が常にこのエラーをスローします。
Invalid value at position X [object Object]' when calling method: [nsIDOMEventListener::handleEvent]
誰かがこのエラーを私に説明できますか?私はこれまで見たことがなく、SOとGoogleを検索しても何も役に立ちませんでした。
どんな助けでもいただければ幸いです。
var heatMapOptions =
{
data: weightedLocations,
dissipating: false,
map: this.googleMap,
gradient: [
'rgba(0, 0, 0, 0)', //black - transparent
'rgba(0, 0, 255, 1)', //blue
'rgba(0, 255, 255, 1)', //cyan
'rgba(0, 238, 0, 1)', //green
'rgba(0, 255, 0, 1)', //lime-green
'rgba(255, 255, 0, 1)', //yellow
'rgba(255, 165, 0, 1)', //orange
'rgba(255, 0, 0, 1)', //red
'rgba(139, 0, 0, 1)' //dark-red
],
maxIntensity: 150,
opacity: 0.6,
radius: 4 //4 pixels
};
//create a Heatmap overlay to sit on top of the google map, passing it the initialization object created above
var heatmap = new google.maps.visualization.HeatmapLayer({ options: heatMapOptions});
オブジェクトが作成される場所
function Box(inBox, count)
{
var box = inBox.toString();
//strip off any sort keys if they exist
if(box.indexOf("~") >= 0) {
box = box.substr(0, box.indexOf('~'));
}
//split box into box number and coordinates of four corners
var splitBox = box.split("_");
//console.log(splitBox);
var boxNumber = splitBox[0];
this.boxNumber = boxNumber.replace("count|", "");
this.swlatlon = new google.maps.LatLng( splitBox[1], splitBox[2]); // a Google LatLng object
this.selatlon = new google.maps.LatLng( splitBox[3], splitBox[4]); // a Google LatLng object
this.nwlatlon = new google.maps.LatLng( splitBox[5], splitBox[6]); // a Google LatLng object
this.nelatlon = new google.maps.LatLng( splitBox[7], splitBox[8]); // a Google LatLng object
this.points = [this.swlatlon, this.selatlon, this.nwlatlon, this.nelatlon] //store all points for easy access
this.count = count; // number of ships in this box
//calculate center of this box
this.bounds = new google.maps.LatLngBounds(this.swlatlon, this.nelatlon);
this.center = this.bounds.getCenter();
this.weightedLocation = { location : this.center, weight : this.count }; // <-- object created here
}
オブジェクトが配列にプッシュされる場所
function parseJsonForModelData(json, datatype) {
for(index in json) {
obj = json[index];
if (index == "Model Data")
{
$j.each(obj, function(k, v)
{
if (datatype == 'heat')
{
box = new Box(k, v);
// Check boxNumber. If null, skip messes up world map!
if (box.boxNumber == 'null')
{
badDataCnt++;
}
else
{
modelData.push(box.weightedLocation); <<- pushed here
}
}
});
}
}
return modelData;
}
WeightedLocations
327: {"location":{"$a":-35.5,"ab":172},"weight":"11"} object music.js:730
328: {"location":{"$a":-36.5,"ab":151},"weight":"1"} object music.js:730
329: {"location":{"$a":-37.5,"ab":151},"weight":"1"} object music.js:730
330: {"location":{"$a":-37.5,"ab":168},"weight":"3"} object music.js:730
331: {"location":{"$a":-37.5,"ab":169},"weight":"6"} object music.js:730
332: {"location":{"$a":-39.5,"ab":161},"weight":"4"} object music.js:730
333: {"location":{"$a":-39.5,"ab":162},"weight":"5"} object music.js:730
334: {"location":{"$a":-39.5,"ab":165},"weight":"6"} object music.js:730