This is my FlexMobileApplication code:

The requirement is on click of a button it should display the Current
Location in a Android Device

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009";
                xmlns:s="library://ns.adobe.com/flex/spark" title="Home">

        <s:layout>
                <s:VerticalLayout />
        </s:layout>

        <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) 
here
-->
        </fx:Declarations>


        <fx:Script>
                <![CDATA[
                        import com.google.maps.LatLng;
                        import com.google.maps.MapEvent;
                        import com.google.maps.MapType;
                        import com.google.maps.controls.PositionControl;
                        import com.google.maps.controls.ZoomControl;

                        import flash.sensors.Geolocation;

                        private var myGeo:Geolocation;

                        protected function 
showBtn_clickHandler(event:MouseEvent):void
                        {
                                if(Geolocation.isSupported == 'true')
                                {
                                        myGeo = new Geolocation();
                                        myGeo.setRequestedUpdateInterval(100);
                                        
myGeo.addEventListener(GeolocationEvent.UPDATE, onUpdate);
                                }
                                else
                                {
                                        myTextArea.text = "Device Not 
Supported";
                                }
                        }


                        private function onUpdate(event:GeolocationEvent):void
                        {
                                myTextArea.text += "Hi"+ "/n"+ 
event.latitude.toString() + "/n" +
                                        event.longitude.toString();

                        }


                        protected function
myMap_mapevent_mapreadyHandler(event:MapEvent):void
                        {
                                myMap.setCenter(new 
LatLng(24,58),9,MapType.NORMAL_MAP_TYPE);
                                myMap.addControl(new ZoomControl);
                                myMap.addControl(new PositionControl);
                        }

                ]]>
        </fx:Script>

        <s:Button id="showBtn" label="Show"
click="showBtn_clickHandler(event)"/>
        <s:TextArea id="myTextArea" width="100%" height="50%" />
        <maps:Map id="myMap" width="100%" height="50%"
                          xmlns:maps="com.google.maps.*"
                          sensor="true"
        
key="ABQIAAAA2Fwy6HLBheYSAWRBEZKwEhRLum8XdHegG17d4EmNgK0o7h2qRRWVBVQywiGHEiGtKahjfGW8xxcRA"
                          
mapevent_mapready="myMap_mapevent_mapreadyHandler(event)"
                          url="http://www.xyz.com"/>

</s:View>



In the above code I am able to get the position based on Latitude and
Longitude.

regards
Prasanth

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to