动态谷歌地图API信息窗口的HTML内容窗口、地图、动态、内容

2023-09-08 15:31:30 作者:随雨而来的泪

我在Flash Builder 4正与谷歌地图的ActionScript API。我创建了一个地图,加载一些自定义的标记到它,并增加了一些的MouseEvent听众每个标记。

I am working in Flash Builder 4 with Google Map's ActionScript API. I have created a map, loaded some custom markers onto it and added some MouseEvent listeners to each marker.

麻烦来当我打开信息窗口面板。我想动态设置基于关的数据库中存储的信息的htmlContent。麻烦的是,这些信息可以改变每两秒钟,每个标记都有一个唯一的数据集,所以我不能静态地在我实际创建标记的时候设置。我会每分钟左右加载所有的从我的数据库中的记录成一个对象变量的方法。我需要的一切,在htmlContent显示下一个唯一的标识符包含在此对象。

The trouble comes when I load an InfoWindow panel. I want to dynamically set the htmlContent based off of information stored in a database. The trouble is that this information can change every couple of seconds and each marker has a unique data set so I can not statically set it at the time I actually create the markers. I have a method that will every minute or so load all of the records from my database into an Object variable. Everything I need to display in the htmlContent is contained in this object under a unique identifier.

问题的根本症结是,有没有办法对我来说,唯一标识信息窗口,所以我也不能确定什么样的信息拉入面板。

The basic crux of the problem is that there is no way for me to uniquely identify an info window, so I can not determine what information to pull into the panel.

marker.addEventListener(MapMouseEvent.ROLL_OVER, function(e:MapMouseEvent):void { showInfoWindow(e.latLng) }, false, 0, false);

这是我的鼠标事件监听器。我所说的功能,showInfowindow看起来是这样的:

That is my mouse event listener. The function I call, "showInfowindow" looks like this:

private function showInfoWindow(latlng:LatLng):void
{
    var options:InfoWindowOptions = new InfoWindowOptions({title: appData[*I NEED A UNIQUE ID HERE!!!*].type + " Summary", contentHTML: appData[*I NEED A UNIQUE ID HERE!!!*].info});
    this.map.openInfoWindow(latlng, options);
}

我以为我到的东西通过能够传递变量在我的事件监听器的声明,但它只是讨厌有一个动态变量通过,它只返回最后一个值使用。

I thought I was onto something by being able to pass a variable in my event listener declaration, but it simply hates having a dynamic variable passed through, it only returns the last value use.

例如:

marker.addEventListener(MapMouseEvent.ROLL_OVER, function(e:MapMouseEvent):void { showInfoWindow(e.latLng, record.unit_id) }, false, 0, false);

这是解决方案是痛苦接近工作。我通过一个循环迭代时,我尝试了上述解决方案,并翻转标记,我得到的信息来创建我的标志,但是每个标记的信息反映的任何信息创建的最后一个标志了。

That solution is painfully close to working. I iterate through a loop to create my markers when I try the above solution and roll over a marker I get information, but every marker's information reflects whatever information the last marker created had.

我为长的解释道歉,但我只是想我的问题尽可能明确。有没有人对如何修补我几乎有-的解决方案,我张贴在从地上爬起来的解决方案?

I apologize for the long explaination but I just wanted to make my question as clear as possible. Does anyone have any ideas about how to patch up my almost-there-solution that I posted at the bottom or any from the ground up solutions?

在此先感谢,

彼得Hanneman的

Peter Hanneman

推荐答案

我创造了一个非常难看的解决方法暂时..

I created a very ugly workaround for the time being..

由于每个标记的经度和放大器;纬度是独一无二的我平添了几分code其中标记被添加到创建所使用的谷歌地图的API的位置对象作为重点,我的唯一标识符的值的散列一个全局可见的关联数组地图。再后来,当我的事件监听器发射,我可以从返回的事件中提取位置对象,散列它,在​​我的数组进行查找和拉动的唯一ID去拉标记特定的信息到信息窗口。

Since each marker's longitude & latitude is unique I added a bit of code where the markers get added to the map that created a globally visible associative array that used a hash of the Google Map's API's location object as the key and my unique identifier as the value. Then later when my event listener fired I could extract the location object from the returned event, hash it, perform a lookup in my array and pull the unique id out to pull marker specific information into the InfoWindow.

这奇妙的作品,但它让我觉得脏。请告诉我有人有一个更好的解决方案?

It works wonderfully, but it leaves me feeling dirty. Please tell me someone has a better solution?