融合层中可以有多少个不同的标记是否有限制? [英] Is there a limit to how many different markers you can have in a fusion layer?
问题描述
我使用融合表图层实现了这种实现,我尝试使用带字母A-Z的预定义标记图标来显示地图上的搜索查询结果(与原始Google地图非常类似)。
我通过首先创建一个图层来为所有标记创建一个通用图标。
var layer = new google.maps.FusionTablesLayer({
query:{
select:'Geometry',
from:0000000
} ,
map:地图,
选项:{
suppressInfoWindows:true
},
风格:[{
markerOptions:{
图标名称: measle_white
}
}]
});同时,我根据我的地图居中的位置,通过ST_DISTANCE排序查询25个结果的同一个表(geopositioned),
var queryUrlHead ='http://www.google.com/fusiontables/api/query?sql= ',
queryUrlTail ='& jsonCallback = success',
query ='SELECT + ID + FROM + 0000000 + ORDER + BY + ST_DISTANCE(Geometry,LATLNG('+ position.coords.latitude +', '+ position.coords.longitude +'))+ LIMIT + 25' ;
var queryurl = queryUrlHead + query + queryUrlTail;
返回的JSON对象是一个唯一ID的数组,我称之为'ids'。然后,我使用一些触发器(zoomchanged)来重新绘制带有字母图标的25个最近的图标(由 )。
google.maps.event.addListener(map,'zoom_changed',function(){
layer.setOptions({
styles:[{
markerOptions:{
iconName:measle_white
}
},//后退
{
其中:''ID'=+ ids.table.rows [0] [0],
markerOptions:{
iconName:a_blue
}
}, {
其中:''ID'=+ ids.table.rows [1] [0],
markerOptions:{
iconName:b_blue
}
},{
其中:''ID'=+ ids.table.rows [2] [0],
markerOptions:{
iconName:c_blue
}
} {
其中:''ID'=+ ids.table.rows [3] [0],
markerOptions:{
iconName:d_blue
}
},{
其中:''ID'=+ ids.table.rows [4] [0],
markerOptions:{
iconName:e_blue
}
},{
其中:''ID'=+ ids.table.rows [5] [0],
markerOptions:{
iconName:f_blue
}
} ,{
其中:''ID'=+ ids.table.rows [6] [0],
markerOptions:{
iconName:g_blue
}
$ b其中:'ID'=+ ids.table.rows [7] [0],
markerOptions:{
iconName:h_blue
}
} {
其中:''ID'=+ ids.table.rows [8] [0],
markerOptions:{
iconName:i_blue
} {
其中:''ID'=+ ids.table.rows [9] [0],
markerOptions:{
iconName: j_blue
}
} {
其中:''ID'=+ ids.table.rows [10] [0],
markerOptions:{
iconName:k_blue
}
},{
其中:''ID'=+ ids.table.rows [11] [0],
markerOptions:{
iconName: l_blue
},{
其中:''ID'=+ ids.table.rows [12] [0],
markerOptions:{
iconName:m_blue
}
},{
其中:''ID'=+ ids.table.rows [13] [0],
markerOptions:{
iconName:n_blue
}
},{
其中:''ID'=+ ids.table.rows [14] [0],
markerOptions :{
iconName:o_blue
}
},{
其中:''ID'=+ ids.table.rows [15] [0],
markerOptions:{
iconName:p_blue
}
},{
其中:''ID'=+ ids.table.rows [16] [0],
markerOptions:{
iconName:q_blue
}
},{
其中:''ID'=+ ids.table.rows [17] [0],
markerOptions :{
iconName:r_blue
}
},{
其中:''ID'=+ ids.table.rows [18] [0],
markerOptions:{
iconName:s_blue
}
},{
其中:''ID'=+ ids.table.rows [19] [0] ,
markerOptions:{
iconName:t_blue
}
},{
其中:''ID'=+ ids.table.rows [20] [0],
markerOptions:{
iconName:u_blue
}
},{
其中:''ID'=+ ids.table.rows [21] [0],
markerOptions:{
iconName:v_blue
}
},{
其中:''ID'=+ ids.table.rows [22] [0 ],
markerOptions:{
iconName:w_blue
}
},{
其中:''ID'=+ ids.table.rows [23 ] [0],
markerOptions:{
iconName:x_blue
}
},{
其中:''ID'=+ ids.table。 rows [24] [0],
markerOptions:{
iconName:z_blue
}
}
]
});
现在,除了前5名的结果AD外, )。这里出了什么问题?我打了一些限制(markerOptions只需要5个值)还是我弄乱了代码?
旁注: 这个例子似乎每层有5个以上的图标,但Google做到了,
解决方案抱歉,只能通过Maps API设置5种样式。 开发人员指南中提到了此限制。
我怀疑显示所有可能图标的地图不是FT图层。如果通过FT用户界面完成,您可以拥有更多样式,但这不是动态的,可能不适合您的情况。
I have this implementation with fusion table layers where I try to use the pre-defined marker icons with letters A-Z to show the result of a search query on map (much like the original google maps does).
The way I achieve this is by first creating a layer, with a generic icon for all markers..
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'Geometry',
from: 0000000
},
map: map,
options: {
suppressInfoWindows: true
},
styles: [{
markerOptions: {
iconName: "measle_white"
}
}]
});
Meanwhile, I query the same table for 25 results with a ST_DISTANCE ordering based on where my map is centered (geopositioned),
var queryUrlHead = 'http://www.google.com/fusiontables/api/query?sql=',
queryUrlTail = '&jsonCallback=success',
query = 'SELECT+ID+FROM+0000000+ORDER+BY+ST_DISTANCE(Geometry,LATLNG('+position.coords.latitude+','+position.coords.longitude+'))+LIMIT+25';
var queryurl = queryUrlHead + query + queryUrlTail;
The returned JSON object is an array of unique ID's which I call 'ids'. I then use some trigger (zoomchanged) to redraw the 25 nearest icons with the letter icons (insprired by this).
google.maps.event.addListener(map, 'zoom_changed', function () {
layer.setOptions({
styles: [{
markerOptions: {
iconName: "measle_white"
}
}, //fallback
{
where: "'ID' = " + ids.table.rows[0][0],
markerOptions: {
iconName: "a_blue"
}
}, {
where: "'ID' = " + ids.table.rows[1][0],
markerOptions: {
iconName: "b_blue"
}
}, {
where: "'ID' = " + ids.table.rows[2][0],
markerOptions: {
iconName: "c_blue"
}
}, {
where: "'ID' = " + ids.table.rows[3][0],
markerOptions: {
iconName: "d_blue"
}
}, {
where: "'ID' = " + ids.table.rows[4][0],
markerOptions: {
iconName: "e_blue"
}
}, {
where: "'ID' = " + ids.table.rows[5][0],
markerOptions: {
iconName: "f_blue"
}
}, {
where: "'ID' = " + ids.table.rows[6][0],
markerOptions: {
iconName: "g_blue"
}
}, {
where: "'ID' = " + ids.table.rows[7][0],
markerOptions: {
iconName: "h_blue"
}
}, {
where: "'ID' = " + ids.table.rows[8][0],
markerOptions: {
iconName: "i_blue"
}
}, {
where: "'ID' = " + ids.table.rows[9][0],
markerOptions: {
iconName: "j_blue"
}
}, {
where: "'ID' = " + ids.table.rows[10][0],
markerOptions: {
iconName: "k_blue"
}
}, {
where: "'ID' = " + ids.table.rows[11][0],
markerOptions: {
iconName: "l_blue"
}
}, {
where: "'ID' = " + ids.table.rows[12][0],
markerOptions: {
iconName: "m_blue"
}
}, {
where: "'ID' = " + ids.table.rows[13][0],
markerOptions: {
iconName: "n_blue"
}
}, {
where: "'ID' = " + ids.table.rows[14][0],
markerOptions: {
iconName: "o_blue"
}
}, {
where: "'ID' = " + ids.table.rows[15][0],
markerOptions: {
iconName: "p_blue"
}
}, {
where: "'ID' = " + ids.table.rows[16][0],
markerOptions: {
iconName: "q_blue"
}
}, {
where: "'ID' = " + ids.table.rows[17][0],
markerOptions: {
iconName: "r_blue"
}
}, {
where: "'ID' = " + ids.table.rows[18][0],
markerOptions: {
iconName: "s_blue"
}
}, {
where: "'ID' = " + ids.table.rows[19][0],
markerOptions: {
iconName: "t_blue"
}
}, {
where: "'ID' = " + ids.table.rows[20][0],
markerOptions: {
iconName: "u_blue"
}
}, {
where: "'ID' = " + ids.table.rows[21][0],
markerOptions: {
iconName: "v_blue"
}
}, {
where: "'ID' = " + ids.table.rows[22][0],
markerOptions: {
iconName: "w_blue"
}
}, {
where: "'ID' = " + ids.table.rows[23][0],
markerOptions: {
iconName: "x_blue"
}
}, {
where: "'ID' = " + ids.table.rows[24][0],
markerOptions: {
iconName: "z_blue"
}
}
]
});
Now, this actually works brilliantly except only for the top 5 results A-D (+1 for the fallback icon). What went wrong here? Did I hit some limit (markerOptions only takes 5 values??) or did I mess up the code?
Sidenote: This example appears to have more than 5 icons per layer, but Google made it and I don't understand any of it.
解决方案 Sorry, but only 5 styles can be set via the Maps API. This limit is mentioned in the developers guide.
I suspect that the map displaying all possible icons is not a FT layer. You can have many more styles if it's done via the FT UI, but that is not dynamic and probably won't work for your situation.
这篇关于融合层中可以有多少个不同的标记是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!