基本上我正在尝试制作Google热图并将其映射到我的oneMap。我正在使用Web服务来执行SQL语句并返回JSON对象。这是我尝试设置热图的地方:
function getHeatMap() {
var gradient = [
'rgba(185, 185, 203, 0)',
'rgba(145, 145, 192, 0)',
'rgba(65, 65, 207, 0)',
'rgba(30, 30, 229, 1)',
'rgba(0, 185, 255, 1)',
'rgba(0, 255, 215, 1)',
'rgba(0, 255, 15, 1)',
'rgba(0, 255, 0, 1)',
'rgba(255, 255, 0, 1)',
'rgba(255, 235, 0, 1)',
'rgba(255, 0, 0, 1)'
]
var data = [];
var max = 0;
$.ajax({
url: "index.aspx/getBusCommuter",
type: "POST",
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var parsed = JSON.parse(data.d);
$.each(parsed, function (i, jsondata) {
var coordXicon = jsondata.BusStopX;
var coordYicon = jsondata.BusStopY;
var commuterAmt = jsondata.CommuterAmt;
var point = new esri.geometry.Point({ "x": coordXicon, "y": coordYicon, "spatialReference": { "wkid": 3414 } });
var count = commuterAmt;
data.push({
location: point,
weight: count
});
if (count > max) {
max = count;
}
var heatmap = new google.maps.visualization.HeatmapLayer({
data: data,
radius: 30,
opacity: 0.8,
maxIntensity: max
});
heatmap.set('gradient', gradient);
heatmap.setMap(map);
});
},
error: function (request, state, errors) {
}
});
}
我检查了检索数据部分,它返回了我想要的所有JSON对象。当我尝试绘制热图时,它会在data.push处向我抛出错误消息Uncaught TypeError: Object #<Object> has no method 'push'
。我想知道为什么会这样。
提前致谢。
答案 0 :(得分:0)
您在哪里定义地图?这可能只是因为该范围内没有 map 。