谷歌地图api v3 - 多个标记,多个infowindows,3个图标 [英] Google maps api v3 - multiple markers, multiple infowindows, 3 icons

查看:176
本文介绍了谷歌地图api v3 - 多个标记,多个infowindows,3个图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作WiFi地图,我有这个问题,我想有3个图标OPEN / WEP / WPA,以及很多标记,每个标记都有自己的infowindow,只有1个infowindow在上面,所以当我点击#1然后点击#2时,#1将隐藏。
如果我将有XXXX标记,那么在缩小地图时会出现问题,有可能使它变得像是在一个地方有多少标记全部不会缩小显示,而是放大显示yes。

我拥有关于MySQL数据库中网络的所有信息,因此在PHP中可以很容易地显示它在官方google maps documentation / v3 / overlays.html#ComplexIcons < - 所以按照这个我可以有例如

  var nodes = [
['WKKOZ',50.192843, 18.967801,nodewep,1],
['airlive',50.193056,18.967974,nodeopen,2],
['Zurawia-3',50.198398,18.974723,nodeopen,3],
[ 'siec dol',50.19303,18.96796,nodewep,4],
['KP_8_1',50.193092,18.96801,nodewep,5],
['Natalia',50.19286,18.967812,nodewpa,6],
['Z104',50.192591,18.967588,nodewep,7],
['D2',50.192499,18.96876,nodewep,8],
['Niesia',50.192474,18.968239,nodewpa ,9],
['boolean',50.192539,18.967545,nodewpa,10],
['n eostrada_0d65',50.192179,18.96758,nodewep,11],
['neostrada_2d38',50.192216,18.96761,nodewep,12],
['Belkin_G_Wireless_9B7BF7',50.192191,18.969261,nodeopen,13],
['Trans_FijPn',50.1939,18.979565,nodeopen,14],
['dlinklis',50.193113,18.968024,nodewpa,15]

请帮助我!:)

BTW:我的MySQL数据库的格式为 http://wklej.to/7Puw/html

解决方案

我最近经历了完全相同的问题,并在Sean Vieira的帮助下设法排除了大部分问题。



这个问题的答案在这里:
在地图上用自己的信息窗口显示多个标记 a>



您的方案的变体是,您只需将一个附加字段添加到您的阵列中d指定您希望使用的标记的URL路径。

然后,循环创建标记(从 var marker = new google .maps.Marker 之后),你可以从数组中调用图标变量的值。



由于您只有三种图标类型,我假设您将从数据库填充记录,因此您需要测试访问点的类型,然后为该标记类型编写相关的URL路径(我是ASP而不是PHP的人,所以原谅使用术语写不正确)。



我的解决方案并不干净地处理信息窗口。一旦他们被打开,他们将保持开放,除非用户手动关闭。我已经看到了解决方案,以打开一个新的解决方案,但还没有实现它们。


I wanna made "WiFi maps" and I have problem with do that, I wanna have 3 icons OPEN/WEP/WPA, and a lot of markers, and every marker with own infowindow, and only 1 infowindow on top, so when I will click #1 and then #2 then #1 will hide. And if I will have XXXX markers there will be problem with them on map in zoom out, there is possible to made it like when is much markers in one place all will not show in zoom out but in zoom in yes?

I have all info about networks in MySQL database, so in PHP will be easy to show it like in tutorial on official google maps documentation/v3/overlays.html#ComplexIcons <- so follow this can I have for example

  var nodes = [
['WKKOZ',50.192843,18.967801,nodewep,1],
['airlive',50.193056,18.967974,nodeopen,2],
['Zurawia-3',50.198398,18.974723,nodeopen,3],
['siec dol',50.19303,18.96796,nodewep,4],
['KP_8_1',50.193092,18.96801,nodewep,5],
['Natalia',50.19286,18.967812,nodewpa,6],
['Z104',50.192591,18.967588,nodewep,7],
['D2',50.192499,18.96876,nodewep,8],
['Niesia',50.192474,18.968239,nodewpa,9],
['boolean',50.192539,18.967545,nodewpa,10],
['neostrada_0d65',50.192179,18.96758,nodewep,11],
['neostrada_2d38',50.192216,18.96761,nodewep,12],
['Belkin_G_Wireless_9B7BF7',50.192191,18.969261,nodeopen,13],
['Trans_FijPn',50.1939,18.979565,nodeopen,14],
['dlinklis',50.193113,18.968024,nodewpa,15]

Please help me!:)

BTW: my MySQL database have format http://wklej.to/7Puw/html

解决方案

I've gone through the exact same problem recently, and managed to sort most of this out with the help of Sean Vieira.

The answer to this question is here: Display multiple markers on a map with their own info windows

The variation for your scenario is that you'd just add an additional field to your array in which you'd specify the URL path to the marker you wish to use.

Then, when looping through to create the marker (from var marker = new google.maps.Marker onwards), you'd call the value from your array for the icon variable.

As you only have three icon types, and I assume you would be populating your record from a DB, you'd test for the type of access point and then write the relevant URL path for the marker type in that place (I'm a ASP and not a PHP man, so excuse the use of the term write isn't correct).

My solution doesn't cleanly deal with infowindows. Once they are opened, they will stay open unless manually closed by the user. I have seen solutions out there to close others as a new one is opened, but haven't got to implementing them as yet.

这篇关于谷歌地图api v3 - 多个标记,多个infowindows,3个图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆