Hello, I have driving directions using google maps api and flex on a
friends site.  I am trying to be able to pass a variable from flex to
a php file.  Basically the flex version of the driving directions is
more of a visual for customers, they also have the option of using a
"printer friendly" (via a button) version which is javascript.  Is
there a way to pass the "From" field in the flex verson to the
javascript version so they don't have to type in there starting(From)
address again?  I am new to flex and have little php experience, any
help would be greatly appreciated!  Here is my code from flex:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
xmlns:maps="com.google.maps.*" layout="absolute" width="100%"
height="100%">
 <mx:Component id="HTMLRenderer">
        <mx:Text width="100%" htmlText="{listData.label}"
selectable="false"/>
 </mx:Component>
   <mx:HDividedBox backgroundColor="#666666" width="100%"
height="100%">
   <mx:VBox backgroundColor="#666666" width="50%" height="100%">
    <mx:Button color="#ffffff" label="Printer Friendly Directions"
click="navigateToURL(new URLRequest('http://www.ox-yokeinn.com/
javadirections'),'_self')"/><mx:Label
      text="Set your (From) location" color="#ffffff"
      width="220"/>
    <mx:HBox>
         <mx:Label
      text="From: " color="#ffffff"
      width="70"/>
     <mx:TextInput
      name="From"
      id="from"
      text=""
      width="100%"/>
    </mx:HBox>
    <mx:HBox>
         <mx:Label
      text="To: " color="#ffffff"
      width="70"/>
     <mx:TextInput
      id="to"
      text="41.74085,-77.66027"
      width="100%"/>
    </mx:HBox>
<mx:Button
     label="Get Directions"
     click="processForm(event);"/>
    <mx:HRule
         width="100%"/>
    <mx:Text
         id="directionsSummary"
         width="100%"/>
    <mx:DataGrid
     id="directionsGrid"
     dataProvider="{directionsSteps}"
     width="100%"
     height="100%"
     sortableColumns="false"
     itemClick="onGridClick(event)">
     <mx:columns>
      <mx:Array>
       <mx:DataGridColumn headerText="Description"
dataField="descriptionHtml" itemRenderer="{HTMLRenderer}"/>
       <mx:DataGridColumn headerText="Distance"
dataField="distanceHtml" width="120" itemRenderer="{HTMLRenderer}"/>
      </mx:Array>
     </mx:columns>
    </mx:DataGrid>
    <mx:Label text="Why the latitude,longitude (To:)? Because ALL MAP/
GPS" color="#ffffff" width="460"/>
    <mx:Label text="software has the incorrect location for our
business." color="#ffffff" width="460"/>
    <mx:Text
         id="directionsCopyright"
         width="100%"/>
   </mx:VBox>
   <maps:Map
     id="map"
 
key="ABQIAAAAwAuwYXeqxC3IwIO8xA6WvhTVCwZBOtg1mIAWlBFngUPAhg8VpxT9gQyGJALNKPs2EUX-34K0wrKO2w"
     mapevent_mapready="onMapReady(event)"
     width="100%" height="100%"/>
  </mx:HDividedBox>

 <mx:Script>
<![CDATA[
import flash.events.Event;
import com.google.maps.MapEvent;
import com.google.maps.Map;
import com.google.maps.InfoWindowOptions;
import com.google.maps.MapType;
import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.overlays.Polyline;
import com.google.maps.overlays.Marker;
import com.google.maps.interfaces.IPolyline;
import com.google.maps.services.*;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.MapType;
import com.google.maps.MapMouseEvent;
import com.google.maps.controls.ZoomControl;
import com.google.maps.controls.PositionControl;
import mx.printing.*;
import mx.printing.PrintDataGrid;
import mx.collections.ArrayCollection;


  [Bindable] public var directionsSteps:ArrayCollection = new
ArrayCollection();

     private function button_click():void {
                System.setClipboard(from.text);
                          }
  private function onMapReady(event:MapEvent):void {
    map.setCenter(new LatLng(41.74085,-77.66027), 14,
MapType.NORMAL_MAP_TYPE);

  var markerA:Marker = new Marker( new LatLng(41.74096,-77.66034), new
MarkerOptions({icon: new CustomIconSprite("")}));
              markerA.addEventListener(MapMouseEvent.CLICK, function
(event:MapMouseEvent):void {
                markerA.openInfoWindow(new InfoWindowOptions({title:
"The Ox Yoke Inn", content: "41.74085,-77.66027"}));
            });
            map.addOverlay(markerA);
            map.addControl(new MapTypeControl());
            map.addControl(new ZoomControl());
            map.addControl(new PositionControl());
          }

  private function processForm(event:Event):void {
    var directions:Directions = new Directions();
    directions.addEventListener(DirectionsEvent.DIRECTIONS_SUCCESS,
onDirectionsSuccess);
    directions.addEventListener(DirectionsEvent.DIRECTIONS_FAILURE,
onDirectionsFail);
    directions.load("from: " + from.text + " to: " + to.text);
  }

  private function onDirectionsFail(event:DirectionsEvent):void {
    Alert.show("Status: " + event.directions.status);
  }

  private function onDirectionsSuccess(event:DirectionsEvent):void {
    map.clearOverlays();
    directionsSteps.removeAll();
    var directions:Directions = event.directions;
    var directionsPolyline:IPolyline = directions.createPolyline();
        map.addOverlay(directionsPolyline);

        var directionsBounds:LatLngBounds = directionsPolyline.getLatLngBounds
();
        map.setCenter(directionsBounds.getCenter());
        map.setZoom(map.getBoundsZoomLevel(directionsBounds));

        var startLatLng:LatLng = directions.getRoute(0).getStep(0).latLng;
        var endLatLng:LatLng = directions.getRoute
(directions.numRoutes-1).endLatLng;
        map.addOverlay(new Marker(startLatLng));
        map.addOverlay(new Marker(endLatLng));

        for (var r:Number = 0 ; r < directions.numRoutes; r++ ) {
                var route:Route = directions.getRoute(r);

                for (var s:Number = 0 ; s < route.numSteps; s++ ) {
                        var step:Step = route.getStep(s);
                        directionsSteps.addItem(step);
                }
        }
  }

  private function onGridClick(event:Event):void {
        var latLng:LatLng = directionsGrid.selectedItem.latLng;
        var opts:InfoWindowOptions = new InfoWindowOptions();
    opts.contentHTML = directionsGrid.selectedItem.descriptionHtml;
        map.openInfoWindow(latLng, opts);
  }

]]>
  </mx:Script>
</mx:Application>


I am using the JavaScript driving directions from Google Maps
playground.  Thank you again!

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