简体   繁体   English

Google用Flex ActionScript映射事件问题

[英]Google maps event problem with flex actionscript

I am able to render a google map on a flex canvas. 我能够在Flex画布上呈现Google地图。 I create the map using the code below and then place markers on it in the onMapReady method (not shown) 我使用下面的代码创建地图,然后在onMapReady方法(未显示)上放置标记

var map:com.google.maps.Map=new com.google.maps.Map();
map.id="map";
map.key="bla bla";
_mapCanvas.addChild(map);
map.addEventListener(MapEvent.MAP_READY,onMapReady);

It all works fine. 一切正常。 However, if I remove the map and then set _mapCanvas to null, then run exactly the same code again, the onMapReady event does not fire. 但是,如果删除地图,然后将_mapCanvas设置为null,然后再次运行完全相同的代码,则不会触发onMapReady事件。 It is weird, but once a map has been created and deleted, the onMapReady event never seems to fire again. 这很奇怪,但是一旦创建并删除了地图,onMapReady事件似乎再也不会触发。

Anyone got any ideas? 任何人有任何想法吗?

Thanks. 谢谢。

I still don't know why this was happening, but I worked around the issue by creating the map as an application-level variable, only instantiating it once, and then adding and removing it from canvases as required. 我仍然不知道为什么会这样,但是我通过将地图创建为应用程序级变量来解决该问题,只实例化了一次,然后根据需要从画布中添加和删除了它。 Not ideal, but at least I can now display and remove a map dynamically, even if it exists in memory between invocations. 这并不理想,但是至少我现在可以动态显示和删除地图,即使它在两次调用之间存在于内存中。

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

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