Dear friend
I have worked so long on this and just can't make it work. Dont know
whats wrong... Trying to add coordinats from an XML document and place
them as markers on Google Maps with attached infwindows?
Can anybody help me with that? I will really appreciate it...
Morten Aggerholm, Denmark
code:
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.controls.ZoomControl;
import com.google.maps.controls.PositionControl;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.overlays.Marker;
import com.google.maps.InfoWindowOptions;
import com.google.maps.MapMouseEvent;
import flash.text.TextFormat;
var map:Map = new Map();
map.key
=
"ABQIAAAAF5GHwa7hgxz5etSP-jJVwhSK_rP-_Usta8fEpiVtC50gLzF69hQ6_VK0zgpArekpmdsRCJK2Vnp60A";
map.sensor = "false";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.x = 0;
map.y = 200;
map.addEventListener(MapEvent.MAP_READY, onMapReady);
//mapcontainer
this.addChild(map);
var markerPin:marker_mc = new marker_mc();
markerPin.width = 20;
markerPin.height = 20;
function onMapReady(event:MapEvent):void {
map.setCenter(new LatLng(55.630346456,12.6350800456), 11,
MapType.NORMAL_MAP_TYPE);
map.addControl(new ZoomControl());
map.addControl(new PositionControl());
map.addControl(new MapTypeControl());
map.openInfoWindow(map.getCenter(), new
InfoWindowOptions({title: "Hello", content: "World"}));
xmlLoader();
map.addOverlay(markerA);
}
var xml:XML;
var xmlList:XMLList;
function xmlLoader(){
function loadXML(event:Event):void{
XML.ignoreWhitespace = true;
xml = XML(event.target.data);
xmlList = xml.children();
for (var i:Number = 0; i < xmlList.length(); i++){
var lat = xmlList.attribute("lat");
var lng = xmlList.attribute("lng");
var MyDescription = xmlList.attribute("MyDescription");
var myTitle = xmlList.attribute("myTitle");
var website = xmlList.attribute("website");
var street = xmlList.attribute("street");
trace(street[0]);
trace(website[0]);
trace(MyDescription[0]);
trace(myTitle[1]);
trace(lng[1]);
trace(lat[1]);
var latlng:LatLng = new LatLng(lat[i],lng[i]);
trace (latLng[1]);
map.addOverlay(latlng,i);
}
function createMarker(latlng):Marker {
var i:Marker = new Marker(
new (latlng),
new MarkerOptions({ icon: this.addChild(markerPin)}));
i.addEventListener(MapMouseEvent.CLICK, function
(event:MapMouseEvent):void {
map.openInfoWindow(event.latLng, new InfoWindowOptions({title: "Hello",
content: "World"}));
}); return i;}} // end function createMarker
} // end of loadXML function
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("data/data.xml"));
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
--
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.