【发布时间】:2011-09-14 23:05:59
【问题描述】:
我正在使用 javascript 和 v3 的地图 API 从 Fusion Table 中提取一些数据。我已经成功地向某些点添加了一些自定义标记,但现在我正在尝试将我创建的标记“默认”设置为从我的表格中名为“图标”的列中指定的图标。我没有使用融合表层,而是在数据的 for 循环中创建标记。我表中的 Icon 列包含以下条目:“poi”、“star”等...
有什么方法可以使用名称字符串以某种方式获取那些“默认”图标,就像融合表层一样?或者,有谁知道我在哪里可以找到默认融合表图标(例如 POI 和 Star)的绝对位置,以便我可以在脚本中定义它们的路径?
这是一些示例代码。如果有人知道谷歌上图标的绝对 URL,我可以编写一个函数来根据“图标”列中的字符串输入它。
//if there's an image, use it as marker, else use default
if(row[3] != ''){
// Create the marker
var marker = new google.maps.Marker({
map: map,
position: coordinate,
icon: new google.maps.MarkerImage(row[3])
});
} else {
// Create the marker
var marker = new google.maps.Marker({
map: map,
position: coordinate
//icon: row[2] (row[2] is the Icon column.
// I'm assuming I'll just need a conditional to check
// for the name (such as 'poi') and then to put in the absolute URL for each respectively
// the problem is I don't know the absolute URL's for these icons. Thanks.
});
}
【问题讨论】:
标签: javascript google-maps google-maps-api-3 google-maps-markers google-fusion-tables