I believe your error is in this line:
var hot = [beaches]
This actually creates an new array with beaches in position zero - run a
trace for hot.length and the variables in the for loop as such:
var hot = [beaches];
trace(hot.length) // my guess is you'll get 1 and not 5
for (var i = 0;i<hot.length;i++){
var beach = beaches[i];
trace(beach.length) /// Here you'll get 5, as in the
original beaches array //
var bLtLng:LatLng = new LatLng (beach[1], beach[2]);
var markerB:Marker = new Marker (LatLng(bLtLng));
}
Try just looping through beaches instead of creating 'var hot'
On Thu, Dec 23, 2010 at 12:54 PM, MrHaley <[email protected]> wrote:
> Hi Everyone,
> I am new to basically everything - Flash, Google API, ActionScript, etc,
> but I've been teaching myself pretty successfully. I am trying to create a
> code that will use an array to create several markers, but for some reason
> it won't overlay the markers. I am sure there is something simple that I am
> missing here, can anyone lead me to my error. Here is the code:
>
> <?xml version="1.0" encoding="utf-8"?>
> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955"
> minHeight="600" xmlns:maps="com.google.maps.*"
> xmlns:ptect="services.ptect.*" xmlns:overlays="com.google.maps.overlays.*"
> xmlns:wrappers="com.google.maps.wrappers.*">
>
> <maps:Map xmlns:maps="com.google.maps.*" id="map"
> mapevent_mapready="onMapReady(event)" width="100%" height="100%" key="taken
> out because I am not sure about security protocol" sensor="true"/>
>
>
> <fx:Script>
> <![CDATA[
> import com.google.maps.InfoWindowOptions;
> import com.google.maps.LatLng;
> import com.google.maps.Map;
> import com.google.maps.MapEvent;
> import com.google.maps.MapMouseEvent;
> import com.google.maps.MapType;
> import com.google.maps.controls.MapTypeControl;
> import com.google.maps.controls.NavigationControl;
> import com.google.maps.overlays.GroundOverlay;
> import com.google.maps.overlays.GroundOverlayOptions;
> import com.google.maps.overlays.Marker;
> import com.google.maps.overlays.MarkerOptions;
>
> import mx.controls.Alert;
> import mx.events.FlexEvent;
>
>
> private function onMapReady(event:Event):void {
> this.map.setCenter(new LatLng(-33,151), 2,
> MapType.SATELLITE_MAP_TYPE);
>
> var MarkerA:Marker = new Marker(
> new LatLng(12,12))
> map.addOverlay(MarkerA);
> map.addOverlay(hot)
>
>
> var beaches:Array = new Array [
> ['Bondi Beach', -33.890542, 151.274856, 4],
> ['Coogee Beach', -33.923036, 151.259052, 5],
> ['Cronulla Beach', -34.028249, 151.157507, 3],
> ['Manly Beach', -33.80010128657071, 151.28747820854187,
> 2],
> ['Maroubra Beach', -33.950198, 151.259302, 1]
> ];
>
>
> var hot = [beaches];
> for (var i = 0;i<hot.length;i++){
> var beach = beaches[i];
> var bLtLng:LatLng = new LatLng (beach[1], beach[2]);
> var markerB:Marker = new Marker (LatLng(bLtLng));
>
>
> }
>
> }
>
> ]]>
> </fx:Script>
> <fx:Declarations>
> <s:CallResponder id="getDataResult"/>
> <ptect:PTect id="pTect" fault="Alert.show(event.fault.faultString +
> '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
> <!-- Place non-visual elements (e.g., services, value objects) here
> -->
> </fx:Declarations>
>
>
> </s:Application>
>
> Thanks!
>
> --
> 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]<google-maps-api-for-flash%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api-for-flash?hl=en.
>
--
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.