0
我無法調用遠程操作並將JSON數據轉換爲時間映射所需的數據格式。時間地圖和地圖抽象地理編碼
- 什麼應該是數據集的類型值:「remote」或「jsonp」?
- 遠程URL中的回調是什麼?需要嗎?
- 在變換方法中,我所擁有的數據只有地址(無緯度值),我該如何將此地址轉換爲緯度值?有沒有一個地圖分割的例子?我不想用mapstraction或谷歌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;
}