将Google Maps嵌入Flash [英] Embedding Google Maps in Flash

查看:112
本文介绍了将Google Maps嵌入Flash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个Flash项目,该项目需要我使用Google Maps.我读了一篇文章,内容为自2011年9月2日起,正式弃用Google Maps API for Flash".我的问题是,是否可以在Flash项目中嵌入Google Maps JavaScript版本?我的另一个问题是,有谁知道我可以用于Flash的任何映射工具,它们提供的质量与Google Maps相同,并且仍受支持吗?谢谢.

I am working on a flash project that requires me to use google maps. I read an article that says "Google Maps API for Flash has been officially deprecated as of September 2, 2011". My question is, is it possible to embed google maps javascript version in a flash project? My other question is, does anyone know of any mapping tools i could use for flash that provide the same quality as google maps and are still being supported? Thank you.

推荐答案

我有相同的需求,也找不到好的现成的解决方案,因此我在下面编写了代码并注释了一个测试库,该库可以作为任何类似内容的基础项目.

I had the same need and also could not find a good ready made solution so I coded and commented a test library below which can serve as the basis for any like project.

我不再依赖单个提供程序,而是在Bing Maps V7,Google Maps V3和MapQuest Maps V7 JavaScript地图中的Flash中实现了相同的功能.该代码创建线,动态标记和阴影等,并调用其高程API.该示例应用程序在一个html页面中创建每种地图类型的两种.

Rather than rely on a single provider I implemented the same functionality in Flash across Bing Maps V7, Google Maps V3 and MapQuest Maps V7 JavaScript maps. The code creates lines, dynamic markers and shadows, etc. and also calls their elevation apis. The sample app creates two of each map type in one html page.

为此,您需要让Flash和JavaScript通过注册具有该项目唯一名称的功能的数据和/或闭包来相互调用.

To do this you need to have Flash and JavaScript call each other with data and/or closure via registering functions which have names unique to that item.

首先,每个地图都有一个唯一的mapId,每个地图MXML组件使用其唯一的mapId(例如fname_mapId)注册一组外部方法,然后为传递mapId的三种地图类型之一创建带有参数化src HTML的Flex-iFrame. ,应用程序名称,开始位置等.

First each map has a unique mapId and each map MXML component registers a set of external methods with their unique mapId (e.g. fname_mapId) and then creates a Flex-iFrame with a parameterized src HTML for one of the three map types passing mapId, application name, start position etc.

HTML读取这些参数,并通过应用程序名称从父框架获取SWF对象.它创建一个映射并向该映射注册侦听器,并使用其mapId(例如fname_mapId)向其父框架添加回调,从而允许创建标记和行,每个标记和行都具有唯一的ID,并再次向当前的父框架注册功能在其名称中还包括标记或行ID(例如fname_mapId_ [lineId | markerId]),这些ID允许设置图标,阴影,线条颜色及其位置更改或删除.

The HTML reads these parameters and gets the SWF object from the parent frame via the application name. It creates a map and registers listeners with the map and adds callbacks to the parent frame using its mapId (e.g. fname_mapId) that allow the creation of markers and lines, each of those with a unique id and again registering functions with the parent frame that now also include the marker-or-line id in their name (e.g. fname_mapId_[lineId|markerId]) that allow setting icons, shadows, line color and their position change or removal.

HTML还通过mapId注册函数,以检查位置或路径的高程.这些调用ajax或例程来请求海拔高度,先返回JavaScript,然后再返回AS3注册的函数.

The HTML also registers functions by mapId to check elevation of a position or a path in general. These call the ajax or routine to request the elevation(s), calling back to the JavaScript and then back to the AS3 registered functions.

-C

测试动作中的逻辑&回调-用于测试所有已实现的功能:

Logic in the test actions & callbacks - designed to test all the implemented functionality:

Double click on map:
    Create pin:
        - Set to default name
        - Add to map
        - Set icon and shadow (note Bing does not take shadows; Google can take a marker mask for clicking - not implemented)
        - Call to map for elevation
    Remove previous marker
    Log current markers (should be only 1)
    Create black line from start to pin:
        - Change line color to blue
        - Call to map for path elevation
    Remove previous line
    Log current lines (should be only 1)
Drag marker:
    Start:
        - only logs it was called
    Drag:
        - only logs it was called
    End:
        - Move line to new lat lng
        - Set line color to orange
        - Sets map to not accept double clicks
Double click marker:
    - Sets map to accept double clicks again (so after you drag you need to double click a marker to have map accept double clicks again)
Elevation callback:
    - Changes pin name to include elevation in name
    - Sets new icon and shadow for marker
Elevation path callback - set to 300m & 500m - is balloon at 500m on path going to hit? - error if elevation of path >=500, warn if >=300
    - Sets line color if path max elevation as sampled is:
        Purple:       elevation request error flag set
        Red:          at or above error level
        Red-Yellow:   at or above warning but requested distance not met
        Yellow:       at or above warning level
        Yellow-Green: below warning level but requested distance not met
        Green:        below warning level

带有代码的文章的其余部分太长了,链接太多了,所以我必须将其全部放在此处-复制到纯文本编辑器中-代码的格式都很好用空格:

The rest of the post with the code was way too long with too many links so I had to put it all here - copy into straight text editor - the code is all very well formatted with spaces: http://pastebin.com/Jzq5E06F

这篇关于将Google Maps嵌入Flash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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