我无法调用远程操作并将 JSON 数据转换为 Timemap 所需的数据格式。
- 数据集的类型值应该是什么:“remote”或“jsonp”?
- 远程 URL 中的回调是什么?是必需的吗?
- 在转换方法中,我拥有的数据只有地址(没有纬度值),我如何将此地址转换为纬度值?有地图绘制的例子吗?我不想用 mapstraction 或 google v3 地图创建另一个地图?
代码片段:
tm = TimeMap.init({
mapId: "map", // Id of map div element (required)
timelineId: "timeline", // Id of timeline div element (required)
datasets: [
{
id: "fdmdata",
title: "FDM Data",
theme: "green",
type: "remote", // or is it type: "jsonp"
options: {
//query: fdmMapQuery,
url: "loadFdmMapData.ge?" +
"orderby=starttime&sortorder=ascending&callback=?",
preloadFunction: preloadData,
transformFunction: transformData,
}
},
],
bandInfo: [
{
width: "85%",
intervalUnit: Timeline.DateTime.MONTH,
intervalPixels: 200,
theme: theme
},
{
width: "15%",
intervalUnit: Timeline.DateTime.DAY,
intervalPixels: 300,
overview: true
}
]
});
});
function transformData(data) {
var title, description, start, end, lat, lon, infoHtml;
var newData = {
"title" : title,
"start" : start,
"end" : end,
"options" : {
"description" : description
}
};
newData["point"] = {
"lat" : lat,
"lon" : lon
};
newData["options"]["infoHtml"] = infoHtml;
return newData;
}
function preloadData(result) {
var entries = (result.feed.entry);
var events = [];
// delete events without geotags
for (var x=0; x<entries.length; x++) {
entry = entries[x];
var location = entry['gd$where'][0].valueString;
var pattern = new RegExp(/@\s*([\-0-9.]+)\s*,\s*([\-0-9.]+)\s*/);
var matches = pattern.exec(location);
if (matches != null) events.push(entry);
}
return events;
}