简体   繁体   English

Google Maps API v3-多个标记,多个信息窗口,3个图标

[英]Google maps api v3 - multiple markers, multiple infowindows, 3 icons

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. 我想制作“ WiFi地图”,但这样做有问题,我想要3个OPEN / WEP / WPA图标,以及很多标记,每个标记都有自己的信息窗口,顶部只有1个信息窗口,所以当我将单击#1,然后单击#2,然后#1将隐藏。 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? 如果我将使用XXXX标记,则在缩小地图时它们会出现问题,有可能使某处的许多标记都不会在缩小中显示,而在放大时显示吗?

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 我在MySQL数据库中拥有有关网络的所有信息,因此在PHP中将像在官方google maps document / 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],
['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 顺便说一句:我的MySQL数据库的格式为http://wklej.to/7Puw/html

I think you are asking about how to have a large number of markers on the map which get hidden at higher zoom levels. 我想您是在问如何在地图上放置大量标记,这些标记在较高的缩放级别下会被隐藏。 This is called marker clustering. 这称为标记聚类。

There are a few Javascript libraries that implement Clustering on the client side and are very easy to integrate into an existing mashup: 有一些Javascript库在客户端实现集群化,并且很容易集成到现有的mashup中:

  • MarkerClusterer - I used this for a mashup and found it easy to integrate, with a nice set of default icons. MarkerClusterer-其用于混搭,发现它易于集成,并带有一组不错的默认图标。
  • ClusterMarker - I haven't used this one, but it seems pretty functional. ClusterMarker-我还没有使用过,但似乎功能不错。

You can also read this blog post which goes over the various alternatives or this blog post which discusses specifics on server side clustering. 您还可以阅读这篇博客文章 ,它讨论了各种替代方法,或者这篇博客文章讨论了有关服务器端集群的细节。

I've gone through the exact same problem recently, and managed to sort most of this out with the help of Sean Vieira. 我最近经历了完全相同的问题,并在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. 您的方案的不同之处在于,您只需在数组中添加一个附加字段,即可在其中指定要使用的标记的URL路径。

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. 然后,在循环创建标记时(从var marker = new google.maps.Marker开始),可以从数组中为icon变量调用值。

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). 由于您只有三种图标类型,并且我假设您将从数据库中填充记录,因此您需要测试访问点的类型,然后在该位置写入标记类型的相关URL路径( ASP而不是PHP专家,因此请原谅使用术语write是不正确的)。

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. 我已经看到解决方案可以在新的解决方案关闭时关闭其他解决方案,但是还没有实现它们。

I know this is an old question, but as I have an answer for it I will write it for future generations to see :) 我知道这是一个老问题,但是当我有一个答案的时候,我会写给后代看看:)

The solution to the infowindow problem can be solved quite easily. 信息窗口问题的解决方案可以很容易地解决。 Make a global variable called currentWindow. 创建一个名为currentWindow的全局变量。 Whenever a user presses a marker the eventlistener checks whether the currentWindow = infoWindow. 每当用户按下标记时,事件监听器都会检查currentWindow = infoWindow。 If not then you close currentWindow and set it to be the new infowindow. 如果不是,则关闭currentWindow并将其设置为新的信息窗口。 Pure and simple, just remember to open the new infowindow as well. 纯净而简单,只需记住还要打开新的信息窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM