Hello,

I'm working on a project that streams a data file located on a server and 
dynamically updates the marker position based on the new variable. I have a 
URLLoader set up on a ENTER_FRAME listener to constantly load the data file. 
Theoretically this would update the values for the variable and update the 
marker position on the map. I've gone through several iterations and feel 
I'm close but keep getting an error in the output.

This is the code (AS3 in Flash CS3), data file attached

import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.MapOptions;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.MapType;
import com.google.maps.LatLng;
import com.google.maps.styles.FillStyle;
import com.google.maps.styles.StrokeStyle;

var map:Map = new Map();
map.key = 
"ABQIAAAAHd1oWFmQAluhsudaMyXOWhSMrb4kdAOmjCYToXTfcs9lB0vBYRQfOrZCZrtlSuT0A4kadCG08XPoEg";
map.sensor = "false";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.addEventListener(MapEvent.MAP_PREINITIALIZE, onMapPreinitialize);
this.addChild(map);

function onMapPreinitialize(event:Event):void {

var myMapOptions:MapOptions = new MapOptions();
myMapOptions.zoom = 12;
myMapOptions.center = new LatLng(40.76629106797523,-77.87853651876857);
myMapOptions.mapType = MapType.PHYSICAL_MAP_TYPE;
this.map.setInitOptions(myMapOptions);
}

map.addEventListener(MapEvent.MAP_READY, onMapReady);

function onMapReady(event:Event):void {
var vehicleOptions:MarkerOptions = new MarkerOptions({
 strokeStyle: {
 color: 0x00FF00,
 thickness: 2
 },
 fillStyle: {
 color: 0x597D12
 },
 label: "test",
 labelFormat: {
 font: "Verdana",
 size: 10,
 bold: true,
 color: 0x000000
 }
 });
var vehicle:Marker = new Marker(map.getCenter(), vehicleOptions);
map.addOverlay(vehicle);
}

addEventListener(Event.ENTER_FRAME, getData, false, 0, true);

function getData(evt:Event):void {
var dataLdr:URLLoader = new URLLoader();
dataLdr.dataFormat = URLLoaderDataFormat.VARIABLES;
dataLdr.load(new URLRequest("data.txt"));

dataLdr.addEventListener(Event.COMPLETE, onComplete, false, 0, true);

function onComplete(evt:Event):void {
evt.target.removeEventListener(Event.COMPLETE, onComplete);
var lat:Number = evt.target.data.latitude;
var lng:Number = evt.target.data.longitude;
var vehicleLocation:LatLng = new LatLng(lat,lng);
vehicle.setLatLng(vehicleLocation);
}
}

I've only been working with CS3 for a few months now, so it's quite possible 
I'm missing something obvious.
Any insight would be greatly appreciated.

Thanks,
mose

-- 
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/-/UfLI0tWrHyAJ.
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.

latitude=40.74053113106079&longitude=-77.87837558622287

Reply via email to