Hi Jesse,

Well, it could be one of two things.

1) You're no longer defaulting the value of "apiKey" in the
constructor.
or
2) You (definitely) need to add the map to the clip before it will
fire the "Ready" event.

Here's an example:

package lib{

import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.Point;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.LatLng;

public class GoogleMap extends MovieClip {
        private var map:Map;
        private const API_KEY:String = "default key goes here";
        public static const EVENT_GOOGLEMAP_READY:String =
"EventGoogleMapReady";

        public function GoogleMap(apiKey:Sting = null) {
                map = new Map();
                map.key = apiKey != null ? apiKey : API_KEY;
                map.addEventListener(MapEvent.MAP_READY, onMapReady);
                addChild(map);
        }

        private function onMapReady(event:MapEvent):void {
                trace('map loaded');
                map.setSize(new Point(stage.stageWidth,
stage.stageHeight));
                map.setCenter(new LatLng(40.736072, -73.992062), 14,
MapType.NORMAL_MAP_TYPE);
                dispatchEvent(new Event(GoogleMap.EVENT_GOOGLEMAP_READY));
        }
}
}

In this example, I added "dispatchEvent" to tell the calling MovieClip
the map is indeed loaded... then you can continue doing other things.

I also like to keep class info contained. Typically, stuff like the
API Key doesn't change (or at least, it shouldn't), but based on your
code, it will accept a key value, and if exists, will use that. If
not, then it will use the default key constant provided above.

Hope this helps out.

<ed/>

On Sep 17, 4:28 pm, Jesse Foltz <[EMAIL PROTECTED]> wrote:
> Thank you the setSize fixed my problem.  I was trying to do as you
> suggested and extend MovieClip instead of Map but couldn't get the map
> to show.  I changed GoogleMap to below but the onMapReady never
> fires.  Do I need to do something different to actually load a Map?
>
> package lib{
>
> import flash.display.MovieClip;
> import flash.events.Event;
> import flash.geom.Point;
> import com.google.maps.Map;
> import com.google.maps.MapEvent;
> import com.google.maps.MapType;
> import com.google.maps.LatLng;
>
> public class GoogleMap extends MovieClip {
>         var map:Map;
>
>         public function GoogleMap(apiKey) {
>                 map = new Map();
>                 map.key = apiKey;
>                 map.addEventListener(MapEvent.MAP_READY, onMapReady);
>         }
>
>         private function onMapReady(event:MapEvent):void {
>                 trace('map loaded');
>                 addChild(map);
>                 map.setSize(new Point(stage.stageWidth, stage.stageHeight));
>                 map.setCenter(new LatLng(40.736072, -73.992062), 14,
> MapType.NORMAL_MAP_TYPE);
>         }
>
> }
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
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