注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

神魔破杜梓的叨叨堂

Programming every day!

 
 
 

日志

 
 
 
 

Flex Google map 组件  

2008-05-22 10:32:27|  分类: My Tech |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
原文来自igorcosta.org

After the release of greatest and awaited API for Flash Platform developers, I decided to facilitate the life of Flex Developers, Created just in some minutes a new component for Flex Developers who want to add more control or be very well organized.

I've created a new Component for Flex. here's how to its works.

Copy and paste this code in your own Path.

ACTIONSCRIPT:
  1. package com.igorcosta
  2. {
  3.     import com.google.maps.LatLng;
  4.     import com.google.maps.Map;
  5.     import com.google.maps.MapEvent;
  6.     import com.google.maps.MapType;
  7.    
  8.     import flash.events.Event;
  9.     import flash.geom.Point;
  10.    
  11.     import mx.core.UIComponent;
  12.     import mx.events.FlexEvent;
  13.  
  14.     public class GoogleFlexMap extends UIComponent
  15.     {
  16.        
  17.         private var _Width:Number = 650;
  18.         private var _Height:Number = 500;
  19.         private var _mapa:Map;
  20.         private var _key:String;       
  21.         public function GoogleFlexMap()
  22.         {
  23.             super();
  24.             super.addEventListener(FlexEvent.INITIALIZE,init);           
  25.         }
  26.         private function init(event:Event):void {
  27.              this.width = _Width;
  28.             this.height = _Height;     
  29.             // Ininitate the Map Object
  30.             _mapa = new Map();
  31.             _mapa.key =_key;
  32.             _mapa.addEventListener(MapEvent.MAP_READY,createUIMap);
  33.             _mapa.setSize( new Point (this.width, this.height))
  34.             // add map to displaylist
  35.             this.addChild(_mapa);
  36.         }
  37.         public function get key():String{
  38.                 return _key;
  39.         }
  40.         public function set key(value:String):void {
  41.             _key = value;
  42.         }
  43.         private function createUIMap(event:Event):void {
  44.             _mapa.setCenter( new LatLng(40.736072,-73.992062),14,MapType.HYBRID_MAP_TYPE);
  45.         }   
  46.     }
  47. }

How to use?

Simple just do that in your main application

XML:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:google="com.igorcosta.*"  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  3.  
  4.     <google: GoogleFlexMap
  5.       key="your_key_goes_here"
  6.       width="100%" height="100%"/>
  7.  
  8. </mx:  Application>
  9.  
  10. <mx>

Very important link before you start.

There's a lot of to do to be more simple as possible, as soon as I get more time I will add more options to automate that.


demo:


  评论这张
 
阅读(1028)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017