Works fine now.

Thanks for the help.

Dan

On Apr 8, 4:55 am, pclinx <[email protected]> wrote:
> Hi Dan,
>
> Declare your "marker" variable as a global rather than local.
>
> Paul
>
> On Apr 7, 9:33 pm, Dan M <[email protected]> wrote:
>
> > I am trying to create some applications where users can add markers to
> > a map and then store the latitude and longitude of the marker in a
> > database. I am using the saveData function from the "From Infowindow
> > to Database" example but I run into a problem with the first two lines
> > of the saveData function. I get an error stating that "marker" is an
> > undefined property. I create the marker in the onMapClick function,
> > how can I access the lat/lng values of the marker in the saveData
> > function? Should the function creating the marker return a value
> > instead of void?  The saveData function is adding values from the
> > comboBox and the description field to the Mysql database. I am very
> > new to Actionscript and would appreciate a newbie type answer.
>
> > Thanks,
>
> > Dan
>
> > Link to app with view source enabled.  I had to comment out the
> > problem code in the saveData function and add code in the saveData
> > function declaring lat and lng as variables in order to export the
> > swf.
>
> >http://www.wisswork.com/carbreak2.html
>
> > Code is below:
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > xmlns:map="com.google.maps.*" xmlns:flexlib="flexlib.controls.*"
> >          layout="absolute" width="100%" height="100%" 
> > viewSourceURL="srcview/
> > index.html">
>
> > <mx:Script>
> >         <![CDATA[
> >                  import mx.controls.Alert;
> >         ]]>
> > </mx:Script>
>
> > <mx:HBox height="100%" width="100%">
>
> > <mx:Panel id="reportProblem"
> >         title="Report Car Break-in"
> >         height="100%"
> >         width="100%"
> >         paddingBottom="5"
> >         paddingLeft="5"
> >         paddingRight="5"
> >         paddingTop="5"
> >         fontFamily="Verdana"
> >         horizontalAlign="left"
> >         verticalAlign="top"
> >         fontSize="10">
> >         <mx:Form id="carBreakIn1">
> >                 <mx:Label text="Location: Click on map or select parking 
> > lot from
> > dropdown menu"
> >                         fontWeight="bold"
> >                         paddingTop="10"/>
> >                 <mx:Label text="Parking Lot Location"
> >                         fontWeight="bold"/>
> >                         <mx:ComboBox id="park" editable="false" 
> > enabled="true">
> >                                 <mx:ArrayCollection>
> >                                 <mx:String>Valley Green Road</mx:String>
> >                                 <mx:String>Wise's Mill Road</mx:String>
> >                                 <mx:String>Valley Green Inn</mx:String>
> >                         </mx:ArrayCollection>
> >                         </mx:ComboBox>
>
> >             <mx:Form includeInLayout="false" visible="false">
> >                 <mx:FormItem label="Day of week" >
> >             <mx:TextInput id="day" width="100"/>
> >         </mx:FormItem>
> >         <mx:FormItem label="Day of month">
> >             <mx:TextInput id="date" width="100"/>
> >         </mx:FormItem>
> >         <mx:FormItem label="Month">
> >             <mx:TextInput id="month" width="100"/>
> >         </mx:FormItem>
> >         <mx:FormItem label="Year">
> >             <mx:TextInput id="year" width="100"/>
> >         </mx:FormItem>
> >         <mx:FormItem label="Date">
> >             <mx:TextInput id="wholeDate" width="100"/>
> >         </mx:FormItem>
> >             </mx:Form>
> >                 <mx:Text text="Description"/>
> >                 <mx:FormItem id="desc"
> >                         label="Description:"
> >                         paddingTop="20"
> >                         fontWeight="bold"
> >                         width="100%"
> >                         required="true">
> >                         <mx:TextArea id="description" width="100%"
> >                                 height="200"
> >                                 restrict="a-z A-Z \-" />
> >                 </mx:FormItem>
>
> >                 <mx:Text id="contact"
> >                         width="100%"
> >                         text="Please add your contact info if we have 
> > additional
> > questions."
> >                         fontWeight="bold"
> >                         paddingTop="20"
> >                         paddingBottom="10"/>
> >                 <mx:FormItem id="contactName" label="Name:">
> >                         <mx:TextInput restrict="a-z A-Z \-"/>
> >                 </mx:FormItem>
>
> >                 <mx:FormItem >
> >                 <mx:Button id="submitBtn" label="Submit"
> > enabled="true" click="saveData()"/>
> >             </mx:FormItem>
> >         </mx:Form>
>
> > </mx:Panel>
> > <mx:Panel title="Wissahickon" width="100%" height="100%"
> > horizontalAlign="center">
> >                 <map:Map
> >                         id="map"
>
> > key="ABQIAAAA7LM75iEnVkcC0EWfpbWivhSVGJuxO4Y265l7a1N7FIWWIgZmihSKvx9HzMW8HD­jln2SuFgBQA5jlmQ"
> >                     mapevent_mappreinitialize="onMapPreinitialize(event)"
> >                         mapevent_mapready="onMapReady(event)"
> >                         width="100%" height="100%" />
> >         </mx:Panel>
> > </mx:HBox>
> >   <mx:Script>
> >         <![CDATA[
> >         import com.google.maps.controls.ScaleControl;
> >         import com.google.maps.LatLng;
> >         import com.google.maps.Map;
> >         import com.google.maps.MapOptions;
> >         import com.google.maps.MapEvent;
> >         import com.google.maps.MapType;
> >         import com.google.maps.MapTypeOptions
> >         import com.google.maps.controls.ZoomControl;
> >         import com.google.maps.controls.ZoomControlOptions;
> >         import com.google.maps.controls.MapTypeControl;
> >         import com.google.maps.controls.MapTypeControlOptions;
> >         import com.google.maps.controls.PositionControl;
> >         import com.google.maps.controls.PositionControlOptions;
> >         import com.google.maps.controls.ControlPosition;
> >         import com.google.maps.interfaces.IMapType;
> >         import mx.utils.ObjectUtil;
> >         import com.google.maps.MapMouseEvent;
> >         import com.google.maps.overlays.Marker;
> >         import com.google.maps.overlays.MarkerOptions;
> >         import com.google.maps.InfoWindowOptions;
>
> >         private function onMapPreinitialize(event:Event):void {
> >            var opts:MapOptions = new MapOptions();
> >            opts.center = new LatLng(40.05659, -75.21888);
> >            opts.zoom = 14;
> >            map.setInitOptions(opts);
> >        }
> >          private function onMapReady(event:MapEvent):void {
> >               map.enableScrollWheelZoom();
> >                   map.enableContinuousZoom();
> >                   map.addControl(new ZoomControl());
> >               map.addControl(new ScaleControl());
> >               map.addControl(new MapTypeControl());
> >               map.addControl(new PositionControl());
> >               map.addEventListener(MapMouseEvent.CLICK, onMapClick);
> >          }
>
> >           public function onMapClick(event:MapMouseEvent):void {
> >                                 // add draggable marker to the map
> >                                 var marker:Marker = new 
> > Marker(event.latLng, new
> > MarkerOptions({draggable: true}));
>
> >                                          map.addOverlay(marker);
> >                                          // prevent the addition of 
> > multiple markers
> >                     map.removeEventListener(MapMouseEvent.CLICK,
> > onMapClick);
> >                                          marker.getLatLng();
>
> >           }
>
> >     public function saveData():void {
>
> >         var lat:Number = marker.getLatLng().lat();
> >         var lng:Number = marker.getLatLng().lng();
> >     var name:String = description.text;
> >     var type:String = park.text;
>
> >     var urlRequest:URLRequest = new 
> > URLRequest("http://www.wisswork.com/phpsqlinfo_addrow.php";);
> >     urlRequest.data = "name=" + name + "&type=" + type + "&lat=" + lat
> > + "&lng=" + lng;
> >     urlRequest.method = URLRequestMethod.GET;
> >     var urlLoader:URLLoader = new URLLoader(urlRequest);
> >     urlLoader.addEventListener("complete", function(e:Event):void {
> >        if (urlLoader.data.length <= 1) {
> >          Alert.show("Successfully added!");
>
> >        } else {
> >             Alert.show("There was an error adding the data :(");
> >        }
> >     });
> >   }
>
> >         ]]>
> >   </mx:Script>
> > </mx:Application>
--~--~---------~--~----~------------~-------~--~----~
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