Search This Blog

Thursday, 19 April 2012

FLEX:How to add a google Map in your Blackberry Playbook app

Hello friends,
              Sorry for not posting from last many days , i was working on Flex,and here i am with the first Post how to add a google map on your blackberry playbook app in flex



Code:(your mxml file):
<fx:Script>
        <![CDATA[
            import com.google.maps.LatLng;
            import com.google.maps.MapEvent;
            import com.google.maps.MapType;
            import com.google.maps.controls.MapTypeControl;
            import com.google.maps.controls.OverviewMapControl;
            import com.google.maps.controls.PositionControl;
            import com.google.maps.controls.ScaleControl;
            import com.google.maps.controls.ZoomControl;
            import com.google.maps.controls.ZoomControlOptions;
            import com.google.maps.overlays.Marker;
            import com.google.maps.overlays.MarkerOptions;
           
            public var timer:Timer = new Timer(10000);
                    
            public var _urlLoader:URLLoader;
            public var _lat:Number;
            public var _lon:Number;
                      
            protected function map_mapevent_mapreadyHandler(event:MapEvent):void
            {
                map.addControl(new ZoomControl());
                map.addControl(new PositionControl());
                map.addControl(new MapTypeControl());
                map.addControl(new ScaleControl());
                map.addControl(new OverviewMapControl());
                map.setCenter(new LatLng(<latitude>,<Longitude>),13,MapType.NORMAL_MAP_TYPE);
                var _marker:Marker=new Marker(new LatLng(<latitude>,<Longitude>));
                this.map.addOverlay(_marker);
                }
           
</fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <maps:Map id="map" x="0" y="0" width="1024" height="600" key="Your API key for GoogleMapsAPI for flash" url="your url" sensor = "true" mapevent_mapready="map_mapevent_mapreadyHandler(event)"/>
   
</s:Application>


Download GoogleMapsApi for Flex.

What you need to do is to unzip the folder and extract the files from there copy "map_flex_1_20.swc to the folder "libs" in your project.
        

No comments:

Post a Comment