Search code examples
androidactionscript-3airmapquest

add a child at an exact latitude and longitude point


I'm using MapQuest (since Google Map API will be down in september) and I'd like to add a point at an exact coordinates position.

I've created a movieClip named geoPoint and traced a circle in it.

Now, I've managed to display the coordinates in a text field like that :

if (Geolocation.isSupported){

var my_geo:Geolocation = new Geolocation();
my_geo.addEventListener(GeolocationEvent.UPDATE, onGeoUpdate);
my_geo.setRequestedUpdateInterval(50);

var my_txt:TextField = new TextField();
my_txt.wordWrap=true; 
addChild(my_txt);

} 

function onGeoUpdate(e:GeolocationEvent):void{
my_txt.text = "My Latitude is "+e.latitude+" and my Longitude is "+e.longitude;
}

Now is it possible to add my movieClip at the e.latitude and e.longitude point ?

I've tried :

var geo:MovieClip;
geo = new geoPoint;
    addChild(geo(new LatLng(e.latitude, e.longitude)));

but it doesn't work.

Someone knows how can I do it ?

Thanks !


Solution

  • It should be

     geo = new geoPoint(); 
    

    You should also probably figure how to translate latitude and longitude to x and y coordinates, because I'm doubtful the next line will work. You're calling a MovieClip constructor that takes a LatLng argument.

    For what you need to achive, you may have to use a class provided by the MapQuest Api, like PolygonOverlay or CircleOverlay. There is an example here under "Shape Collections" http://developer.mapquest.com/content/as3/v7/7.0.6_MQ/samples/samplesexplorer/index.html#