Guys

Thanks a lot for all the input.
Shaun, your advice was spot on. Casting type did the trick. Will continue
updating that example to suit my needs.

As for my first issue, please find additional info below:

*MapSimple.mxml*

 <?xml version="1.0" encoding="utf-8"?>
<mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml";
 xmlns:maps="com.google.maps.*"
 width="640"
 height="480"
 layout="absolute"
 creationComplete="creationCompleteHandler(event)">

 <maps:Map
  id="map"
  sensor="false"
  key="API_KEY"
  mapevent_mapready="onMapReady(event)"
  width="100%"
  height="100%"/>

 <mx: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.controls.ZoomControl;
   import com.google.maps.overlays.Marker;
   import com.google.maps.overlays.MarkerOptions;
   import com.google.maps.services.ClientGeocoder;
   import com.google.maps.services.ClientGeocoderOptions;
   import com.google.maps.services.GeocodingEvent;

   import mx.controls.Alert;
   import mx.core.FlexGlobals;
   import mx.events.FlexEvent;

   private var CinemaName:String;
   private var CinemaPostCode:String;

   private function onMapReady(event:Event):void {
    map.enableScrollWheelZoom();
    map.enableContinuousZoom();
    map.addControl(new ZoomControl());
    map.setZoom(15);
    doGeocode(CinemaPostCode);
   }

   private function doGeocode(PostCode:String):void {

    var geocoder:ClientGeocoder = new ClientGeocoder();

    geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS,
     function(event:GeocodingEvent):void {

      var placemarks:Array = event.response.placemarks;

      if (placemarks.length > 0) {

       map.setCenter(placemarks[0].point);
       var options:MarkerOptions = new MarkerOptions(
        {label: "Here",
         tooltip: CinemaName,
         hasShadow: true,
         clickable: false,
         draggable: false,
         radius: 16});

       var marker:Marker = new Marker(placemarks[0].point,options);

       marker.addEventListener(MapMouseEvent.CLICK,
        function (event:MapMouseEvent):void {
         marker.openInfoWindow(new InfoWindowOptions({content:
placemarks[0].address}));
        });

       map.addOverlay(marker);

      }

     });

    geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE,
     function(event:GeocodingEvent):void {

      Alert.show("Geocoding failed");
      trace(event);
      trace(event.status);

     });

    geocoder.geocode(PostCode);

   }
   protected function creationCompleteHandler(event:FlexEvent):void
   {
    CinemaPostCode=FlexGlobals.topLevelApplication.parameters.PostCode;
    CinemaName=FlexGlobals.topLevelApplication.parameters.CinemaName
   }
  ]]>
 </mx:Script>
</mx:Application>

*Separate application (lets call it MapLoader.mxml):*

*SimpleMapPopup.mxml (component used as popup):*
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009";
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    layout="absolute"
    width="642"
    height="513"
    title="Cinema Location"
    showCloseButton="true"
    close="PopUpManager.removePopUp(this)"
    creationComplete="creationCompleteHandler(event)">

 <fx:Script>
  <![CDATA[

   import mx.events.DragEvent;
   import mx.events.FlexEvent;
   import mx.managers.PopUpManager;

   [Bindable] private var SWFLoaderURL:String;

   public var PostCode:String;
   public var CinemaName:String;
   public static const   simple_map_url:String="
http://www.SomeDomain.com/MapSimple.swf";;

   protected function creationCompleteHandler(event:FlexEvent):void
   {
    SWFLoaderURL=simple_map_url + "?PostCode=" + PostCode + "&CinemaName=" +
CinemaName;
    SimpleMapLoader.source=SWFLoaderURL;
    SimpleMapLoader.load();
   }
  ]]>
 </fx:Script>

 <mx:Canvas width="100%" height="100%">

  <mx:SWFLoader
   id="SimpleMapLoader"
   width="640"
   height="480"/>

 </mx:Canvas>

</mx:TitleWindow>

*Calling popup from main application:*

    var SimpleMapPU:SimpleMapPopup =
SimpleMapPopup(PopUpManager.createPopUp(this, SimpleMapPopup, true));

    SimpleMapPU.PostCode=PostCode;
    SimpleMapPU.CinemaName=CinemaName;

    PopUpManager.centerPopUp(SimpleMapPU);

As I mentioned, if I will render map (MapSimple.swf) inside the browser (new
tab) without flex popup (wrapper) all the controls works fine. Only when
rendered inside Flex popup some controls go totally bonkers or simply dont
work.

Regards
Michael


On Tue, Aug 30, 2011 at 5:24 AM, Daniel <[email protected]> wrote:

> Maybe the first problem could be solved by using this.whatever you are
> doing. It has been so long since I used swfloader. Try that and see if it
> works. I'll read about swfloader and see if I can help.
> On Aug 29, 2011 7:19 PM, "Michael (London)" <[email protected]> wrote:
> > Hello Experts
> >
> > I have started using Google APIs recently (distances matrix and Flash
> APIs).
> >
> > At the moment I am building a non-commercial application in Flash Builder
>
> > 4.5 for PHP. I have decided to incorporate 2 types of maps:
> >
> > - Simple map with single location (using Geocoding)
> > - More complex map with Driving Directions
> >
> > I have come across following issues:
> >
> > 1. I have successfully developed Simple map with single location as
> > a standalone Flex application. I am passing 2 parameters (as FlashVars)
> > namely postcode and location description (for marker) when calling this
> map.
> > It works perfectly fine. The only glitch (real deal breaker) is that when
> I
> > use popup (with Flex SWFLoader object) to display it inside my main Flex
> > application some of the map features (zoom -/+ buttons, dragging of the
> map)
> > do not work. These features work perfectly fine when I am displaying swf
> in
> > a new browser window (using Flex URLRequest object). I would prefer
> though
> > (as you can imagine) to continue using popups inside main Flex. It seems
> to
> > me that some of the events of Flash API do not work with certain
> wrappers.
> > Please note that some events do work just fine like zooming with scroll
> of
> > the mouse or by clicking on a zoom scale (using slider on scale does not
> > work as expected though)
> > 2. I have tried to develop map with Driving Directions using Google
> > sample code (see url:
> >
> http://code.google.com/p/gmaps-samples-flash/source/browse/trunk/samplecode/DirectionsAdvanced.mxml)
>
> > however I am getting following compile error:
> >
> > 1118: Implicit coercion of a value with static type
> > com.google.maps.interfaces:IDirections to a possibly unrelated type
> > com.google.maps.services:Directions
> >
> > for following line of the code:
> >
> > var dir:Directions = event.directions;
> >
> > Upon closer inspection both objects Directions and event.directions have
> > exactly same structure
> >
> >
> > Can anyone offer some help in solving these issues?
> > Regards
> > Michael
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Google Maps API For Flash" group.
> > To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-api-for-flash/-/dNv0Bptvy-AJ.
> > 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.
> >
>
> --
> 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.
>

-- 
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