Hi

Sorry by my english. I´m creating a pplication with Flex. The idea is
read a remote xml file with points to show in a google map as markers
with a windows and information it it.

The problem is with the data in the map.openInfoWindow only show the
last record of the xml file. Do you help me!


The section of code  with the problem is:

                var marker : Marker = new Marker( latlng, markerOptions );

                                        // se agrega ventana  marcador con 
mayor informacion
                                        var mivariable:String = da...@location;
                                        var html:String = "<i>Hola 
Mundo"+mivariable+"</b>";
                                marker.addEventListener(MapMouseEvent.CLICK, 
function
 
(event:MapMouseEvent):void
                        {
                        map.openInfoWindow( event.latLng,
                        new InfoWindowOptions({title: "Información",
contentHTML:html,
                            width:300, drawDefaultFrame:true}));
                        });

                    map.addOverlay(marker);


When i run the program only show the location of the last xml record
for all marks in the maps.






This is the complete  code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml";
        layout="absolute" creationComplete="dataSeting.send(); onInitialize
();"
        viewSourceURL="srcview/index.html"
        preloader="preload.CustomPreloader"
    backgroundGradientColors="[#ffffff, #ffffff]">

        <mx:Script>
                <![CDATA[
                        import mx.events.ListEvent;
                        import mx.events.ItemClickEvent;
                        import mx.controls.advancedDataGridClasses.SortInfo;
                        import com.google.maps.overlays.MarkerOptions;
                        import com.google.maps.styles.FillStyle;
                        import com.google.maps.styles.StrokeStyle;
                        import com.google.maps.overlays.*;
                        import mx.controls.dataGridClasses.DataGridColumn;
                        import com.google.maps.interfaces.IMapType;
                        import com.google.maps.LatLng;
                        import com.google.maps.Map;
                        import com.google.maps.MapEvent;
                        import com.google.maps.MapType;
                        import com.google.maps.controls.*;

                    import mx.rpc.events.ResultEvent;
                        import com.google.maps.InfoWindowOptions;
            import com.google.maps.MapMouseEvent;

            import mx.controls.LinkButton;
                        import flash.net.URLRequest;
                        import flash.net.navigateToURL;


                        [Bindable]
                        private var dataSet:XML;

                        private var map:Map;
                        private var minTemp : Number = 0;
                        private var maxTemp : Number = 65;
                        private var minColor : int = 0xFF0000;
                        private var maxColor : int = 0x0000FF;
                        private var minColorObj : Object;
                        private var maxColorObj : Object;
                        private var delta : Object;




                private function contactResultHandler(event:ResultEvent):void{
                            dataSet = event.result as XML;
                }

                        private function onInitialize() : void
                        {

                                minColorObj = intToRgb( minColor );
                                maxColorObj = intToRgb( maxColor );
                                delta = { r: ( maxColorObj.r - minColorObj.r ),
                                                  g: ( maxColorObj.g - 
minColorObj.g ),
                                                  b: ( maxColorObj.b - 
minColorObj.b )
                                                };
                        }

                        public function getTempColor( temp : Number ) : int
                        {
                                var percentage : Number = (temp / maxTemp);
                                return ( ( maxColorObj.r - percentage * delta.r 
) << 16 )
                       + ((maxColorObj.g - percentage * delta.g ) <<
8 )
                       + ( maxColorObj.b - percentage * delta.b );
                        }


                        /*
                        Adapted color tween method originally found at:
                        http://www.darronschall.com/weblog/archives/000251.cfm
                        */
                        public static function intToRgb( color:int ):Object
                    {
                        var r:int = ( color & 0xFF0000 ) >> 16;
                        var g:int = ( color & 0x00FF00 ) >> 8;
                        var b:int = color & 0x0000FF;
                        return {r:r, g:g, b:b};
                    }

                    public function colorLabelFunction( value : *, column :
DataGridColumn ) : String
                    {
                        return getTempColor( parseFloat( [email protected]
() ) ).toString(16);
                    }


                        public function onContinerInitialize( event:Event ):void
                        {
                            map = new Map();
                            map.key = "PUT API KEY HERE";
                            map.addEventListener( MapEvent.MAP_READY, 
onMapReady );

                            //control de zoom
                                map.addControl(new ZoomControl());
                                //control de posicion
                                map.addControl(new PositionControl());
                                //selector de tipo de mapa
                                map.addControl(new MapTypeControl());

                            mapContainer.addChild( map );

                        }

                        public function onContainerResize( event:Event ):void
                        {
                            map.setSize( new Point( mapContainer.width,
mapContainer.height ) );
                        }

                        private function onMapReady( event:Event ):void
                        {
                            map.enableScrollWheelZoom();
                            map.enableContinuousZoom();
                            map.setCenter(new LatLng(-33.133, -64.35), 7,
MapType.NORMAL_MAP_TYPE );


                            for each ( var data : XML in dataSet.data )
                            {
                                var latlng:LatLng = new LatLng( parseFloat( 
da...@lat ),
parseFloat( da...@lon ) );
                                var markerOptions : MarkerOptions = new 
MarkerOptions({
                                        strokeStyle: new StrokeStyle({color: 
0x000000}),
                                        fillStyle: new FillStyle({color: 
getTempColor( parseFloat
( [email protected]() ) ), alpha: 0.8}),
                                        radius: 12,
                                        hasShadow: true
                                      })
                                        markerOptions.tooltip = 
[email protected]() + ":    " +
[email protected]() + " F";

                                var marker : Marker = new Marker( latlng, 
markerOptions );

                                        // se agrega ventana  marcador con 
mayor informacion
                                        var mivariable:String = da...@location;
                                        var html:String = "<i>Hola 
Mundo"+mivariable+"</b>";
                                marker.addEventListener(MapMouseEvent.CLICK, 
function
(event:MapMouseEvent):void
                        {
                        map.openInfoWindow( event.latLng,
                        new InfoWindowOptions({title: "Información",
contentHTML:html,
                            width:300, drawDefaultFrame:true}));
                        });

                    map.addOverlay(marker);

                            }

                                // Agregar enlace a GeoINTA sobre el mapa
                                        var clickMore:LinkButton = new 
LinkButton();
                                        clickMore.percentWidth = 18;
                                        clickMore.label = "Visitar GeoINTA";
                                        
clickMore.addEventListener(MouseEvent.CLICK, function
(e:MouseEvent):void {
                                                var request:URLRequest = new 
URLRequest("http://
geointa.inta.gob.ar");
                                                navigateToURL(request, 
"_blank");
                                                 });
                                        addChild(clickMore);



                        }

                        private function sortNumeric( obj1 : *, obj2 : * ) : int
                        {
                                var val1 : Number = parseFloat( 
[email protected]() );
                                var val2 : Number = parseFloat( 
[email protected]() );

                                if ( val1 > val2 )
                                        return -1;
                                if ( val1 < val2 )
                                        return 1;
                                return 0;

                        }

                        private function onGridItemClick( event : ListEvent ) : 
void
                        {
                                var data : XML = event.itemRenderer.data as XML;
                                if ( data )
                                        map.setCenter( new LatLng( parseFloat( 
da...@lat ), parseFloat
( da...@lon ) ) );
                        }
                ]]>
        </mx:Script>



    <!-- Cargo datos de un archivo XML externo y remoto-->
    <mx:HTTPService id="dataSeting" url="http://127.0.0.1:4000/
temperaturas.xml"
                    result="contactResultHandler(event)"
resultFormat="e4x"/>




        <!-- Esta marca es la encargada de definir dos áreas horizontalas en
apantalla-->
        <mx:VDividedBox width="100%" height="100%">

                <!-- UIComponent es el primer contenedor de la pantalla donde se
insertará el mapa -->
                <mx:UIComponent id="mapContainer"
                initialize="onContinerInitialize(event);"
                resize="onContainerResize(event)"
                width="100%" height="100%"/>


                <!-- Defino que ne la parte inferior se inserta una estructura 
de
tabs -->
            <mx:TabNavigator width="100%" height="200">

                    <!-- Defino el primer tab -->
                    <mx:Canvas width="100%" height="100%" label="Listado de
Ciudades">
                                <mx:DataGrid dataProvider="{ dataSet.data }" 
width="100%"
height="100%" itemClick="onGridItemClick(event)">
                                        <mx:columns>
                                                <mx:DataGridColumn 
headerText="Location" dataField="@location" /
>
                                                <mx:DataGridColumn 
headerText="Avg Jan Temp"
dataField="@janTemp" sortCompareFunction="sortNumeric" />
                                                <mx:DataGridColumn 
headerText="Latitude" dataField="@lat" />
                                                <mx:DataGridColumn 
headerText="Longitude" dataField="@lon" />
                                                <mx:DataGridColumn 
headerText="Color"
labelFunction="colorLabelFunction"
itemRenderer="components.ColorRenderer" />
                                        </mx:columns>
                                </mx:DataGrid>
                    </mx:Canvas>

                        <!-- Defino el segundo tab -->
                <mx:Canvas width="100%" height="100%" label="Acerca de...">

                        <mx:TextArea editable="false" width="100%" 
height="100%">
                    <!-- Inserto texto HTML en un tab -->
                                <mx:htmlText>
                                        <![CDATA[<b>Qué es esto?</b>
<p>Esto es un ejemplo acerca de como trabajar on los elementos
gráficos relacionados con mapas, bla, bla, bla...</p>
<p>Se puede insertar html sin ningún problema, así como enlaces a
otras partes, por ejemplo a mi <a href="http://
ferbor.blogspot.com">blog</a> </p>
<p>lameb simbut te comiyum denber acicatum etnis lasertis ah va codex
sei tutus lameb simbut te comiyum denber acicatum etnis lasertis ah va
codex sei tutus alba salga contoda totre lader mullkait solle fiud
fresdtiok alo jujuan sai toga onga mocha alga canda salo tuitui remo
hkaiko sango juniter masker lanmarker duncher suimer sastum gairi
jukaste acalite chengo lameb simbut te comiyum denber acicatum etnis
lasertis ah va codex sei tutus lameb simbut te comiyum denber acicatum
etnis lasertis ah va codex sei tutus lameb simbut te comiyum denber
acicatum etnis lasertis ah va codex sei tutus lameb simbut te comiyum
denber acicatum etnis lasertis ah va codex sei tutus lameb simbut te
comiyum denber acicatum etnis lasertis ah va codex sei tutus lameb
simbut te comiyum denber acicatum etnis lasertis ah va codex sei tutus
lameb simbut te comiyum denber acicatum etnis lasertis ah va codex sei
tutus lameb simbut te comiyum denber acicatum etnis lasertis ah va
codex sei tutus lameb simbut te comiyum denber acicatum etnis lasertis
ah va codex sei tutus</p>
                                        ]]>
                                </mx:htmlText>
                        </mx:TextArea>

                </mx:Canvas>
            </mx:TabNavigator>

        </mx:VDividedBox>



</mx:Application>

This is the XMLfile

<?xml version="1.0" encoding="UTF-8"?>
<dataset>
                          <data location="Lujan, BA" janTemp="44" lat="-34.58" 
lon="-59.16"/
>
                          <data location="Lujan de Cuyo, ME" janTemp="38" 
lat="-33.05"
lon="-68.866"/>
                          <data location="Amaicha del Valle, TU" janTemp="35" 
lat="-26.55"
lon="-65.917"/>
                          <data location="Los Reartes, CO" janTemp="31" 
lat="-31.916"
lon="-64.583"/>
                          <data location="Los Angeles, CA" janTemp="47" 
lat="34.3"
lon="-118.7"/>
                          <data location="San Francisco, CA" janTemp="42" 
lat="38.4"
lon="-123.0"/>
                          <data location="Denver, CO" janTemp="15" lat="40.7" 
lon="-105.3"/
>
                          <data location="Ojo de Agua, CA" janTemp="22" 
lat="-28.466"
lon="-65.45"/>
                          <data location="Realico, LP" janTemp="26" 
lat="-35.033"
lon="-64.25"/>
                          <data location="San Francisco, CO" janTemp="30" 
lat="-31.433"
lon="-62.083"/>
                          <data location="Jacksonville, FL" janTemp="45" 
lat="31.0"
lon="-82.3"/>
                          <data location="Pico Truncado, SC" janTemp="35" 
lat="-46.8"
lon="-67.966"/>
                          <data location="Miami, FL" janTemp="58" lat="26.3" 
lon="-80.7"/>
                          <data location="Atlanta, GA" janTemp="37" lat="33.9" 
lon="-85.0"/
>
                          <data location="Boise, ID" janTemp="22" lat="43.7" 
lon="-117.1"/>
                          <data location="Chicago, IL" janTemp="19" lat="42.3" 
lon="-88.0"/
>
                          <data location="Indianapolis, IN" janTemp="21" 
lat="39.8"
lon="-86.9"/>
                          <data location="Des Moines, IA" janTemp="11" 
lat="41.8"
lon="-93.6"/>
                          <data location="Wichita, KS" janTemp="22" lat="38.1" 
lon="97.6"/>
                          <data location="Louisville, KY" janTemp="27" 
lat="39.0"
lon="86.5"/>
                          <data location="New Orleans, LA" janTemp="45" 
lat="30.8"
lon="90.2"/>
                          <data location="Portland, ME" janTemp="12" lat="44.2" 
lon="70.5"/
>
                          <data location="Menucos, RN" janTemp="25" 
lat="-39.616"
lon="-67.083"/>
                          <data location="Boston, MA" janTemp="23" lat="42.7" 
lon="71.4"/>
                          <data location="Detroit, MI" janTemp="21" lat="43.1" 
lon="83.9"/>
                          <data location="Minneapolis, MN" janTemp="2" 
lat="45.9"
lon="93.9"/>
                          <data location="St. Louis, MO" janTemp="24" 
lat="39.3" lon="90.5"/
>
                          <data location="Helena, MT" janTemp="8" lat="47.1" 
lon="112.4"/>
                          <data location="Omaha, NE" janTemp="13" lat="41.9" 
lon="96.1"/>
                          <data location="San Marcos Sierra, CO" janTemp="11" 
lat="-30.783"
lon="-64.65"/>
                          <data location="Atlantic City, NJ" janTemp="27" 
lat="39.8"
lon="75.3"/>
                          <data location="Albuquerque, NM" janTemp="24" 
lat="35.1"
lon="106.7"/>
                          <data location="Albany, NY" janTemp="14" lat="42.6" 
lon="73.7"/>
                          <data location="New York, NY" janTemp="27" lat="40.8" 
lon="74.6"/
>
                          <data location="Charlotte, NC" janTemp="34" 
lat="35.9" lon="81.5"/
>
                          <data location="Raleigh, NC" janTemp="31" lat="36.4" 
lon="78.9"/>
                          <data location="Bismarck, ND" janTemp="0" lat="47.1" 
lon="101.0"/
>
                          <data location="Cincinnati, OH" janTemp="26" 
lat="39.2"
lon="85.0"/>
                          <data location="Cleveland, OH" janTemp="21" 
lat="42.3" lon="82.5"/
>
                          <data location="Oklahoma City, OK" janTemp="28" 
lat="35.9"
lon="97.5"/>
                          <data location="Portland, OR" janTemp="33" lat="45.6" 
lon="123.2"/
>
                          <data location="Harrisburg, PA" janTemp="24" 
lat="40.9"
lon="77.8"/>
                          <data location="Philadelphia, PA" janTemp="24" 
lat="40.9"
lon="75.5"/>
                          <data location="Charleston, SC" janTemp="38" 
lat="33.3"
lon="80.8"/>
                          <data location="Nashville, TN" janTemp="31" 
lat="36.7" lon="87.6"/
>
                          <data location="Amarillo, TX" janTemp="24" lat="35.6" 
lon="101.9"/
>
                          <data location="Galveston, TX" janTemp="49" 
lat="29.4" lon="95.5"/
>
                          <data location="Houston, TX" janTemp="44" lat="30.1" 
lon="95.9"/>
                          <data location="Salt Lake City, UT" janTemp="18" 
lat="41.1"
lon="112.3"/>
                          <data location="Burlington, VT" janTemp="7" 
lat="45.0" lon="73.9"/
>
                          <data location="Norfolk, VA" janTemp="32" lat="37.0" 
lon="76.6"/>
                          <data location="Seattle, WA" janTemp="33" lat="48.1" 
lon="122.5"/
>
                          <data location="Spokane, WA" janTemp="19" lat="48.1" 
lon="117.9"/
>
                          <data location="Madison, WI" janTemp="9" lat="43.4" 
lon="90.2"/>
                          <data location="Milwaukee, WI" janTemp="13" 
lat="43.3" lon="88.1"/
>
                          <data location="Cheyenne, WY" janTemp="14" lat="41.2" 
lon="104.9"/
>
</dataset>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" 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/google-maps-api-for-flash?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to